i’ve been searching all over the Answer for countdown timer, but the most better code i could understand a little is this code…
but now i don’t understand how to stop it… so the code is here…
var seconds = 60;
private var textMesh : TextMesh;
function Start () {
textMesh = GameObject.Find ("Timer").GetComponent(TextMesh);
textMesh.text = seconds.ToString();
InvokeRepeating ("Countdown", 1.0, 1.0);
}
function Countdown () {
if (--seconds == 0) CancelInvoke ("Countdown");
textMesh.text = seconds.ToString();
//if(Input.GetKeyDown("a")){
// CancelInvoke("Countdown");
//}
}
So i want to stop the timer for the rest of the time, and store the value to any variable… but i’m so confused how to do it…
could anybody help me to explain a bit which way to do this?