Create, Compete & Win at Redbrick Connect 2024! 🎉
SnippetCreate Save Point

Create Save Point


Example

Code

🚫

Don’t forget to check Body in the object’s properties panel to use methods like onCollide!

Physics -> Body

let startLocation = WORLD.getObject("StartLocation(aa3)");
 
function Start() {
  // 4 save points form spawn1 ~ spawn4
  for (let i = 1; i < 5; i++) {
    const point = WORLD.getObject("spawn" + i);
 
    point.onCollide(PLAYER, () => {
      startLocation = point;
    });
  }
}
 
function Update(dt) {
  //respawn when avatar y position is less than -5
  if (PLAYER.position.y < -5) {
    PLAYER.spawn(startLocation);
  }
}