Hi guys.
I have a problem with my little scoring system. Wonder if u guys can help me out. Once again, I’ve been following the tutorials on catlikecoding.com to sharpen up my C# skills.
My scoring system is based on how far a player has traveled (like the function used in the tutorial)
In my Runner.cs Script:
distanceTraveled = transform.localPosition.x;
GUIManager.SetDistance (distanceTraveled);
Now I have managed to add a new variable for high score on a guitext which displays my last score achieved after the game over screen and shows up when u reset the scene. But, here’s my problem and concern : Whenever the game ends now and the scene resets it uses the previous score achieved and doesn’t keep the highest value achieved, meaning I might was well rename it to previous score instead of high score.
In my Runner.cs Script for setting score:
highScore = distanceTraveled;
If (distanceTraveled > highScore) {
GUIManager.SetScore (highScore);
}
else if (distanceTraveled < highScore) {
//(I haven't set anything here as I'm not sure wtf I can use here, and believe me I have tried)
}
In my GUIManager.cs Script:
public static void SetScore (float highScore) {
instance.highScore.text = highScore.ToString ("f0");
}
So my question is, how do I keep the highest distance traveled value in my high score variable for the remainder of that game session?
PS: Once again, if I don’t make any sense, just curse me. Have to do this from my phone again seeing as this god forsaken country haven’t installed my internet line yet.
Thanks in advance.