How do I make a checkpoint?

So I am making a horror game and there is a part where you have to run away from a bunch of enemies. If you die then I want the player to respawn right before the enemies started to chase. Like a checkpoint. Can anybody help?

Hi @PhilipJeffrey!

A checkpoint is basically just an empty entity or position. So you can create an entity in your scene and call it Checkpoint. When the player dies you can use the position of this entity to respawn the player.

this.entity.rigidbody.teleport(this.app.root.findByName('Checkpoint').getPosition());
2 Likes

Thank you so much! Is there any way to reset some entities like the monster will go back to where original position when the chase starts again?

You can copy the start position of the monster in the initialize function and use this position to reset the monster.

// initialize
this.startPosition = this.entity.getPosition().clone();
// reset 
this.entity.rigidbody.teleport(this.startPosition);
1 Like

Thanks you! This really helped!

1 Like