Question by
MiniatureGames · Dec 30, 2017 at 06:21 PM ·
c#score
Best Score Counter
I've made this script to save the Best Score:
public Text highScore;
public Transform player;
// Use this for initialization
void Start ()
{
highScore.text = PlayerPrefs.GetInt("HighScore", 0).ToString();
}
// Update is called once per frame
public void high ()
{
int number = Mathf.RoundToInt(player.position.z);
if (number > PlayerPrefs.GetInt("HighScore", 0))
{
PlayerPrefs.SetInt("HighScore", number);
highScore.text = number.ToString();
}
}
}
The problem is that the BestScore text and the Player ( int number = Mathf.RoundToInt(player.position.z) are in 2 different scenes, and I need the (player.position.z) from the scene 2
Comment
Your answer
Follow this Question
Related Questions
Best server-side score storage service 0 Answers
My UI Score Is Not Working? 1 Answer
Scoring system not working. 1 Answer