I’m trying to get a simple countdown timer to reset after a given time.
The first time it runs fine (starts at 12 and resets to 12), the second time it resets to 24, the third time to 48 and so on…
#pragma strict
var timer : float = 12.0;
var ionCannonDeployed : AudioClip;
function Update ()
{
timer -= Time.deltaTime;
if(timer <= 0)
{
Reset();
}
else
if(timer <= 6)
{
//audio.PlayOneShot(ionCannonDeployed);
//And do other uber cool stuff
}
}
function OnGUI()
{
GUI.Box(new Rect( 100, 10, 140, 20), "" + timer.ToString("0"));
}
function Reset()
{
timer = Time.time;
}
What am I missing guys ???