Question by
AndrewMac26 · Mar 09, 2016 at 08:58 PM ·
coroutinecountdown
321 Countdown Coroutine stuck on 3
So im trying to make a Coroutine that will count down from 3 whilst the Time.timeScale is set to 0 but it only ever displays the 3 then if Time.timeScale is still zero it freezes and if Time.timeScale is 1 then it displays the 3 then the game resumes any idea why this might be?
Coroutine Calling in the update method :
if (counting) {
Time.timeScale =0f;
score = 0;
scoreText.text = "Score: 0";
StartCoroutine (GameCountdown());
Time.timeScale = 1f;
counting = false;
}
Coroutine:
IEnumerator GameCountdown()
{
countdownText.text = "3";
yield return new WaitForSeconds (1f);
countdownText.text = "2";
yield return new WaitForSeconds (1f);
countdownText.text = "1";
yield return new WaitForSeconds (1f);
countdownText.text = "GO!";
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612071213im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Getting variable from script while keeping other code from it 1 Answer
My code is not working - HELP - IEnumerator Coroutines 0 Answers
Execute coroutine in Update() 8 Answers
yield ends method 0 Answers
MoveTowards and Lerp not working 1 Answer