To start this one off you need to declare a Vector3 variable which will be used to store the location of the checkpoint. Open up your script and add in the code shown below.
This Vector3 will be used store the position of the checkpoint when the player enters it. It will also be used to reset the players position when they die or are killed, depending on the type of game you're implementing this in. Next you need to set up the checkpoint. For the purpose of this tutorial I'm going to use a cube as the trigger.
![]() |
The Red box will work as my checkpoint. |
Now you have the checkpoint set up open up your script again to add a new void, this new void will be an OnTriggerEnter void. This void will take care of storing the checkpoints position in the Vector3 that you created earlier. Add the code shown in the screenshot below underneath void Update.
This is almost all of the code you need to make the checkpoints work. Before adding the last bits of code you need to create a new tag, if you look at the if statement that you just added in the new piece of code you will see that the script will look for a "Checkpoint" tag whenever it enters a trigger.
![]() |
Clicking the button highlighted in the box will open the drop down tag menu. |
![]() |
This is the drop down menu that will appear after clicking on the tag option. |
From the second menu that pops up click on one of the empty boxes and type the word Checkpoint into one of them. Go back to the Hierarchy and select your checkpoint object and set its tag to Checkpoint by selecting the tag you just created from the drop down list. Now this tag is set scroll down to the objects Box Collider and make sure the Is Trigger box is ticked.
![]() |
Make sure this box is ticked. It's key to making the code work. |
Now you have the main parts of the script setup and the necessary boxes ticked to make things work you need to add the last pieces of code. Open up your script again and add in the code shown below.
![]() |
Final piece of code! |
Adding in this code now means that whenever the players Y position becomes less than 0 it will reset the players position to the same position as the checkpoint. Alternatively you can add the code shown below to make it so that when the player enters a trigger tagged as Death or Dead, essentially creating a death zone/barrier.
![]() |
This code isn't necessary but still works as a good alternative. |
This is pretty much all there is to this tutorial! Let me know if this works or if you have any problems with this tutorial by contacting me on Twitter @markimo2 or alternatively leave a comment on this post. Also keep your eyes peeled for a video version of this tutorial.