Hello I really need some help with this one. I have a scoring system that increases by one every 4 seconds to give the illusion that it is the distance that gives the score. Anyway how do I:
Save the score and put it onto the next screen?
How do I Save a highscore and put it onto the next screen?
To save the highscore between two scenes, you can prevent your Score Manager to be destroyed when loading a new scene with the function DontDestroyOnLoad
To save highscore between games, the simplest way is to use PlayerPrefs in my opinion
PlayerPrefs. You’re looking for SetInt and GetInt in particular:
//save current distance travelled
PlayerPrefs.SetInt("distanceTravelled", distance);
//When loading a level and you want to keep the distance from the last level
distance = PlayerPrefs.GetInt("distanceTravelled");
//save highscore
int oldHighscore = PlayerPrefs.GetInt("Highscore");
if(distance > oldHighscore)
PlayerPrefs.SetInt("Highscore", distance");