How to make a checkpoint?

Was wondering if anyone knows any c# script for creating a checkpoint in a level so when a player reaches the checkpoint and dies the level will be resetted back to the checkpoint. Any help will be appreciated.

  1. create a class/structure that isn’t a MonoBehaviour, one that stores all the things you want saved at this checkpoint (character’s position, character’s direction, current health, and current weapons are some examples of something you want to save)

  2. create a trigger collider for your checkpoint

  3. write a script that:

  • saves the details into an static instance of that structure on trigger enter
  • turns off the trigger collider
  1. attach the script to your checkpoint object

  2. On character respawn, use the static instance of your structure to place your character back to the state he was when he triggered the checkpoint.

This should give you an idea of what direction to go in. This will not save your data outside of a play session. If you intend on doing that, you should look up the terms “data serialization/deserialization”