Create Save Point
Code
๐ซ
Donโt forget to check Body in the objectโs properties panel to use methods
like onCollide
!
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);
}
}