- Home /
Why does this script just quit and not countdown first?
I am using this count down script to auto quit when it counts down to 0
It counts down in the play mode and after i build it quits as soon as the game starts ?
Any ideas why
Thanks
#pragma strict
var timer : float = 60.0;
function Update()
{
timer -= Time.deltaTime;
if(timer <= 0)
{
timer = 0;
Application.Quit();
}
}
function OnGUI()
{
GUI.Box(new Rect(10, 10, 50, 20), "" + timer.ToString("0"));
}
Comment
my bet is frame rate. proly runs really fast.
try changing the update to FixedUpdate and Time.deltaTime to FixedDeltaTime
Check documentation for spellings
Answer by Taxen0 · Dec 17, 2014 at 11:23 AM
You should have a look at Coroutines instead, they are perfect for this =)
Your answer
Follow this Question
Related Questions
Countdown code not working 1 Answer
How to make a coundown of destroyed objects ? 1 Answer
3D number countdown 0 Answers
how to make a varied countdown timer 1 Answer
Time goes to fast for the code. (C#) 2 Answers