- Home /
Question by
Nirvoak · Jun 11, 2015 at 10:37 AM ·
eventsystemcountdown
Wait in Coroutine doesn't work
I tried to implement a countdown timer after the user has hit the resume game option. The option is just a text with event trigger set to OnMouseDown attached to it. The text also has a pause script which reads:
public void pauseGame() {
if (!pause) {
pauseNoJump = true;
Time.timeScale = 0f;
pause = true;
pauseText.text = "►";
}
else
{
pauseText.text = "||";
StartCoroutine(StartingUp());
}
}
IEnumerator StartingUp() {
pauseText.text = "3";
yield return new WaitForSeconds(1);
pauseText.text = "2";
yield return new WaitForSeconds(1);
pauseText.text = "1";
yield return new WaitForSeconds(1);
pauseNoJump = true;
pause = false;
Time.timeScale = 1f;
pauseText.text = "||";
}
but it doesn't go pass the first WaitForSeconds. My guess is so how something gets destroyed in a even trigger and the coroutine hangs up. The text does changed to 3 meaning the coroutine started. Any ideas what could've been done? Thank you
Comment
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