Reset a scene but save checkpoints.

I’v searched around about resetting a scene and

Application.LoadLevel(Application.loadedLevel);

seems to be the most popular solutions which works great. But in my scene I have checkpoints (triggers) that moves the spawn point. On level load the spawn point is moved back to it’s original position.

I did try add

DontDestroyOnLoad (gameObject);

in the checkpoint script but no luck as this only creates another spawn point at start.

Anyone got a solution to this?

This can be a complex problem. DontDestroyOnLoad can get messy if you are not surgically precise with it. Can you post your checkpoint script and describe the GameObject that you would attach it to.

2 Answers

2

You could try moving your checkpoints to be static variables, which do not get destroyed on scene reload.

Otherwise, create your own solution for reloading a level rather than doing Application.LoadLevel

You could try making your checkpoint a trigger which sends you to another scene with the same layout