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

How do I get my endless runner high score,How do I make high score for an endless runner

$
0
0
Hello, the script works as far as keeping up with the score, however it doesn't save the high score as predicted. I would appreciate the help and Thank in advance. public Transform player; public Text scoreText; public Text highScoreText; private float score; private float highScore; void Start() { highScoreText.text = highScore.ToString(); highScore = PlayerPrefs.GetFloat("HighScore", highScore); } void Update() { scoreText.text = score.ToString("0"); score = player.position.z; if (score > highScore) { PlayerPrefs.SetFloat("HighScore", highScore); highScore = score; } } ,This scripts works but however, it doesn't save the highScore on the UI. I would appreciate the help and Thank you in advance.` public Transform player; public Text scoreText; public Text highScoreText; private float score; private float highScore; void Start() { highScoreText.text = highScore.ToString(); highScore = PlayerPrefs.GetFloat("HighScore", highScore); } void Update() { scoreText.text = score.ToString("0"); score = player.position.z; if (score > highScore) { PlayerPrefs.SetFloat("HighScore", highScore); highScore = score; } }`

Viewing all articles
Browse latest Browse all 1333

Trending Articles



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