Hi guys, I've never done a timer in Unity before and I was wondering if anyone could help me out with getting time to display on the screen?
This is the script I'm working with:
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();
}
I've applied the script to an empty game object and I added a text mesh to the object, but I don't know how to display the time on-screen so the player knows how much time they have left.
Also I'm guessing it's a very simple case of telling the timer to load a different level when it gets to 0? (I'd like it to go to a Game Over screen!)
Thanks in advance guys :).