Quantcast
Channel: Answers for "Save and display a highscore"
Viewing all articles
Browse latest Browse all 4

Answer by Infernospeed

$
0
0
You might want to look into [PlayerPrefs][1] Here is an example, int Highscore = 0; void Start() { //loading highscore Highscore = PlayerPrefs.GetInt("MyHighscore"); InvokeRepeating("CreateObstacle", 1f, 1.5f); } void CreateObstacle() { Instantiate(rings); score++; //saving highscore Highscore = PlayerPrefs.SetInt("MyHighscore",score); } PlayerPrefs.SetInt may have a slight performance issue if called every frame ( especially on mobiles). So try to save at the end of the scene, on exit or at some checkpoint. [1]: http://docs.unity3d.com/ScriptReference/PlayerPrefs.html

Viewing all articles
Browse latest Browse all 4

Trending Articles



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