Quantcast
Channel: Questions in topic: "playerprefs"
Viewing all articles
Browse latest Browse all 1333

PlayerPrefs not saving my variable value for HighScore System

$
0
0
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**

Viewing all articles
Browse latest Browse all 1333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>