Return to original position when it falls
In this example you can make it by simply checking PLAYER
’s Y
position.
function Update(dt) {
//respawn when PLAYER y position is less than -5
if (PLAYER.position.y < -5){
PLAYER.spawn();
}
}
In this example you can make it by colliding to a mesh under your world.
Place object under your world
Place the mesh where you want it and resize it. Check Body, and make sure Anchored is checked.
![respawn_step-1](/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Frespawn_step-1.374dac51.png&w=3840&q=75)
Make mesh transparent
Use the Opacity to adjust the transparency.
![respawn_step-2](/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Frespawn_step-2.9f3c3c98.png&w=1080&q=75)
Create a place to return to its original location
Click the Spawn that you want to create -> place a StartLocation
![respawn_step-3](/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Frespawn_step-3.6f81b6bb.png&w=3840&q=75)
Insert Code
const spawnbox = WORLD.getObject("BOX(b5d)");
function Start() {
// use here spawn related logic
spawnbox.onCollide(PLAYER, () => {
PLAYER.spawn();
});
}
![respawn_result](/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Frespawn_result.28787e5c.gif&w=3840&q=75)