Hello Christopher, we've created some code as an example for you. Here, the bunny starts moving randomly when you click it and returns to its starting point after some time.
You should be able to adapt the code for your purposes:
var rabbit = Space.createItem('LP_Rabbit', 0, 0, 0);
var base = { x: 0, y: 0, z: 0 };
var turns = 5;
function randNumBetween(min, max) {
return Math.random() * (max - min) + min;
}
function moveRandomly() {
rabbit.say('moving randomly');
if(turns > 0) {
rabbit.move(randNumBetween(-3, 3), randNumBetween(-3, 3), 0, moveRandomly);
turns--;
} else {
rabbit.say('returning to base');
rabbit.moveTo(base.x, base.y, base.z);
turns = 5;
}
}
rabbit.onActivate(moveRandomly);
I hope we could help you with this!