I can't create a timer code for my prank game. Whenever I try something new I get errors or it does not work. Please help my game.
1 Answer
1Try This:
private var timeLeft: float = 0;
var totalTime: float = 3;
function Start()
{
timeLeft = totalTime;
}
function Update()
{
timeLeft -= time.deltaTime;
if(timeLeft < 0)
{
//Do what you want here when time runs out.
//if you want it to repeat itself over and over add keep the next line
timeLeft = totalTime;
//if you do not want it to repeat delete the line above.
}
}
Great solution helped me too :)
– zinnfandelwhat can you add to make the game stop or pause when the time runs out?
– RickHurd