Create, Compete & Win at Redbrick Connect 2024! 🎉
SnippetCreating an object that moves repeatedly

Creating an object that moves repeatedly

Place the object

Place the objects where the stepping stone should disappear and change the title.

Code

const movebox = WORLD.getObject("BOX(f7b)");
const patrol = new TWEEN.Tween(movebox.position)
  .to({ x: "-10" }, 2000)
  .repeat(Infinity)
  .yoyo(true)
  .start();
🚫

If you turned on the Body in Physics and it appears stationary, don’t worry. Simply add a few lines (onUpdate) to the tween, as demonstrated below.

const movebox = WORLD.getObject("BOX(f7b)");
const patrol = new TWEEN.Tween(movebox.position)
    .to({ x: "-10" }, 2000)
    .repeat(Infinity)
    .onUpdate(()=>{movebox.body.needUpdate = true;})
    .yoyo(true)
    .start();

Result