Ok, so I have this code in my restart scene for setting up a highScore variable, if its bigger than the previous one.
private var scoreSaver : float;// Time of survive
private var playerHighScore : float; // Time of survive for highscore uses
private var storeHighScore : float = 0;
function Start ()
{
scoreSaver = PlayerPrefs.GetFloat("Time Survived"); //Retrieves my survive time of previous code(I've set up it correctly in other code)
playerHighScore = PlayerPrefs.GetFloat("High Score"); Retrieves my survive time of previous code. Equals above, but I need two of this timer, because one of them resets every restart button click.
if (scoreSaver >= playerHighScore && scoreSaver >= storeHighScore)
{
storeHighScore = playerHighScore;
}
}
In the restart button, I have this:
PlayerPrefs.DeleteKey("Time Survived");
**The problem is that every time I play, the storeHighScore doesn't get its value, it gets reseted, so I'm always having a new highScore, event if its lower than the previous one**
↧