I’m making a racing game and I trying to delay the game for 3 seconds so I can start a 3,2,1 countdown. However yield WaitForSeconds isn’t doing anything.
function Start() {
Time.timeScale = 0;
beginingofgame();
}
function beginingofgame()
{
Debug.Log("Game CountDown");
Time.timeScale = 0;
countdowntimertostartgame();
Time.timeScale = 1;
}
function countdowntimertostartgame()
{
yield WaitForSeconds(3);
}
If timeScale is 0, WaitForSeconds with any number above 0 will take forever (literally). There’s no reason to set timeScale to 0; you can leave that out and just do WaitForSeconds(3). Do whatever functions are needed to start the race after that.
–Eric
the problem is the game doesn’t even pause. I can’t get it to stop let a count down happen then start the game.
function Start () {
for (i = 3; i >= 1; i--) {
guiText.text = i.ToString();
yield WaitForSeconds(1.0);
}
guiText.text = "GO!";
StartRace();
}
–Eric
Try adding the Time.timeScale = 1; to the countdowntimertostartgame function, after the yield.