I have a scene that keeps track of the score, player lives, etc… when the player finishes the level I load a new scene that gives a recap of how the player did. When I load the next scene (level) I lose my info on score and lives. Why? Is it because the variables are being reinitialized? If so, how should I go about keeping this info from scene to scene? These variables are being handled in the player control script.
Thanks for any help
Steve
PS sorry if this belongs in the scripting area. Thought maybe there might be something unique for the iPhone.
Thanks Danneman, I actually tried that. It resulted in two copies of my player when I got to the next level. Maybe I am missing something.
When you load a new scene your player is already loaded.
function Awake () {
DontDestroyOnLoad (this);
}
causes the player from the first scene to be carried over to the next scene. You must already have a player in the next scene. that is why you have two now. You will have to delete the players in the subsequent scenes because the player from your first scene will carry over to the next.
you can also try PlayerPrefs:
You can store stores in memory when the scene ends and recall them when the next scene starts if you did not want to go with the DontDestroyOnLoad
Quietus proposes a third option that Ive used successfully in the link above.