//creates a camera and positions itvar camera = Scene.getCamera();camera.setPosition(0, 0, 2);camera.setPlayerCamera();
var player = Scene.createItem('LP_Wom', 0, 0, 0);
var snowmen = [Scene.getItem('snowman1'),Scene.getItem('snowman2'),Scene.getItem('snowman3'),Scene.getItem('snowman4')];function spawnSnowman(snowman) {var xSpawn = Math.random() * 30 - 15;var ySpawn = Math.random() * 30 - 15;snowman.setPosition(xSpawn, ySpawn, 0);snowman.moveTo(0, 0, 0);}function init() {snowmen.forEach(function(snowman) {spawnSnowman(snowman);});}init();Scene.scheduleRepeating(function() {snowmen.forEach(function(snowman) {if(snowman.distanceToItem(player) < 1) {spawnSnowman(snowman);}});}, 0);
var player = Space.createItem('LP_Wom', 0, 0, 0);var scoreBoard = Space.createTextBillboard(4,8,1); scoreBoard.setSize(2,1,2); var score = 0; scoreBoard.setText('Score' + '=' +score);
var snowmen = [ Space.getItem('snowman1'), Space.getItem('snowman2'), Space.getItem('snowman3'), Space.getItem('snowman4'), Space.getItem('snowman5')];
function spawnSnowman(snowman) { var xSpawn = Math.random() * 30 -15 ; var ySpawn = Math.random() * 30 - 15; snowman.setPosition(xSpawn, ySpawn, 0); snowman.moveTo(0,0,0); snowman.onActivate(function(){ score++; scoreBoard.setText('Score'+ '=' + score); spawnSnowman(snowman); });
}
function init() {
snowmen.forEach(function(snowman) { spawnSnowman(snowman); }); }
init();
Space.scheduleRepeating(function() { snowmen.forEach(function(snowman) { if(snowman.distanceToItem(player) < 1) { spawnSnowman(snowman); } });}, 0);
var player = Scene.createItem('LP_Wom', 0, 0, 0);var scoreBoard = Scene.createTextBillboard(4, 8, 1);scoreBoard.setSize(2, 1, 2);
var score = 0;scoreBoard.setText('Score' + ' = ' + score);
var snowmen = [Scene.getItem('snowman1'),Scene.getItem('snowman2'),Scene.getItem('snowman3'),
Scene.getItem('snowman4'),Scene.getItem('snowman5')
];function spawnSnowman(snowman) {var xSpawn = Math.random() * 30 - 15 ;var ySpawn = Math.random() * 30 - 15;
snowman.setPosition(xSpawn, ySpawn, 0, true);
snowman.moveTo(0, 0, 0);}function init() {snowmen.forEach(function(snowman) {spawnSnowman(snowman);
snowman.onActivate(function(){snowman.stopMovement();
score++;scoreBoard.setText('Score' + ' = ' + score);spawnSnowman(snowman);});
});}init();Scene.scheduleRepeating(function() {
snowmen.forEach(function(snowman) {if(snowman.distanceToItem(player) < 1) {spawnSnowman(snowman);}});}, 0);
// helper functionsfunction Vector(x, y, z) {this.x = x || 0;this.y = y || 0;this.z = z || 0;}Vector.prototype.mult = function (s) {this.x = this.x * s;this.y = this.y * s;this.z = this.z * s;};Vector.prototype.mag = function () {return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);};Vector.prototype.normalize = function () {var mag = this.mag();this.x = this.x / mag;this.y = this.y / mag;this.z = this.z / mag;};Vector.sub = function (v1, v2) {return new Vector(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);};function setCustomMoveMethods(obj) {obj.cMoveToItem = function (otherItem, speed) {var self = this;this.faceTo(otherItem);this.pos = this.getPosition();var otherPos = otherItem.getPosition();var start = new Vector(this.pos.x, this.pos.y, this.pos.z);var dest = new Vector(otherPos.x, otherPos.y, otherPos.z);var dir = Vector.sub(dest, start);dir.normalize();dir.mult(0.03 * speed);this.update = Scene.scheduleRepeating(function () {self.pos = self.getPosition();self.setPosition(self.pos.x + dir.x, self.pos.y + dir.y, self.pos.z + dir.z);if (self.distanceToItem(otherItem) < 0.5) {self.update.dispose();}}, 0);};obj.cStopMovement = function () {this.update.dispose();};}// end helper functionsvar player = Scene.createItem('LP_Wom', 0, 0, 0);var scoreBoard = Scene.createTextBillboard(4, 8, 1);scoreBoard.setSize(2, 1);
var score = 0;scoreBoard.setText('Score' + ' = ' + score);
var snowmen = [Scene.getItem('snowman1'),Scene.getItem('snowman2'),Scene.getItem('snowman3'),
Scene.getItem('snowman4'),Scene.getItem('snowman5')
];function spawnSnowman(snowman) {var xSpawn = Math.random() * 30 - 15;var ySpawn = Math.random() * 30 - 15;
snowman.setPosition(xSpawn, ySpawn, 0, true);snowman.cMoveToItem(player, 0.5);}function init() {snowmen.forEach(function (snowman) {setCustomMoveMethods(snowman);spawnSnowman(snowman);snowman.onActivate(function () {snowman.cStopMovement();
score++;scoreBoard.setText('Score' + ' = ' + score);spawnSnowman(snowman);});
});}init();Scene.scheduleRepeating(function () {snowmen.forEach(function (snowman) {if (snowman.distanceToItem(player) < 0.5) {spawnSnowman(snowman);}});}, 0);
Thanks for the scripts. I haven't had the chance to work on the my scene yet but will shortly. You've been a big help!
var cam = Scene.getCamera();cam.setPosition(0, -60, 30);
var cam = Scene.getCamera();cam.setPosition(0, -60, 30);
cam.setCameraAH(0, -Math.PI / 4);
var cam = Scene.getItem('Camera');cam.addLocalRotation(0, 0, 0, 1, 0, 0, Math.PI / 4);