- Home /
Please work through some tutorials.
checkpoint
(sorry for the bad english)
Hey ! I have a player, when his life goes to 0, the player get deleted, I would like to make like checkpoints with trigger zones and when my player dies the scene "reset" and the player goes to the last checkpoint he passed but I don't know where to start, thanks.
Answer by Jeff-Kesselman · Jun 29, 2014 at 01:30 AM
The only real "reset" mechanism in Unity is to reload a scene.
If you want check-points within the scene that reset the state, you are going to have to build your own code to do that.
It might be possible to write code that traversed the scene graph and saved specific information (position,rotation, acceleration, etc) but you'll still have to write that code yourself.
Answer by EvilTak · Jun 29, 2014 at 04:15 AM
First, create triggers for your checkpoints. In the OnTriggerEnter function, store the last checkpoint into a variable in the main script. When the player dies, use DontDestroyOnLoad() and Application.LoadLevel() to reload the level (For that you will need to go to File -> Build Settings and set your levels) and then change the position of the player back to the checkpoint's location. You can check out the scripting API here and here.
Follow this Question
Related Questions
2D Game Checkpoint System 1 Answer
Checkpoints in a platformer 1 Answer
Checkpoint in c# 0 Answers
save funtion c# 1 Answer
problems with check point in unity 0 Answers