Stop counter when game over and store the value
Hello guys,
For my new game in unity, i create a java script that allows to count when the player is playing and display the value in a GUIText.
But i have some issues.
In the game, the count start and the GUIText shows the value of the count. But when i come to the game over, the count doesn't stop.
In the quit scene, the GUIText that shows the value of the count of the game scene, restart from 0 and it don't stop.
here is the script:
var Counter : int = 0;
var score : GUIText;
function Start () {
}
function Update () {
Counter++;
score.text = Counter.ToString();
}
So what i want to do is to stop the count when the game over comes, and store the value so in the next scene, the GUIText shows the final value.
How can i do that?
Thanks a lot :)
Regards, Ophélia.
private bool timerEnabled = false;
void Update () {
if (timerEnabled)
{
Counter++;
score.text = Counter.ToString();
}
}
Granted, that's C#, but you should get the point.
When GameOver is detected, timerEnabled = false. Counter will stop counting..
Thanks for your reply,
timerEnabled exists in Java? (sorry i just begin... :3)
and can the script detect when it's a game over event from playmaker?
well i just did the same for Java and i have the same problem, the count still continue and restart in the "quit" scene and it don't stop.
any ideas?
Your answer
Follow this Question
Related Questions
Basic Unity: Can someone explain the referencing and instantiation process? 1 Answer
Having transitions between two VideoPlayers triggered by clicking "x" times in a text layer 0 Answers
How to solve java.lang.ClassNotFoundException ? 0 Answers
how to make a max number on counter. 1 Answer
How do you add +1 to a score counter after a destroy script (C#)? 1 Answer