Question by
abishekpoudel2014 · Dec 09, 2019 at 01:04 AM ·
guitimer
How to make a timer that freezes the game after you hit resume
i made a function that freezes time for 3 sec and another function that counts and displays 321 for the player to get ready to play . This function works fine at the start of the game but when i try to implement it in my resume button it doesnt show countdown just freezes for 3 sec This first one freezes time and the second one counts and shows time The first one works on start function and update but the second one only works on start
IEnumerator GameTimer() {
//CountDownText();
counterText.SetActive(true);
Time.timeScale = 0f;
float pauseTime = Time.realtimeSinceStartup + 3;
while (Time.realtimeSinceStartup < pauseTime)
{
yield return 0;
}
counterText.SetActive(false);
Time.timeScale = 1;
}
void CountDownText()
{
float pauseTime = Time.realtimeSinceStartup + 3;
if (Time.realtimeSinceStartup < pauseTime)
{
countdown -= 1 * Time.fixedDeltaTime;
countDownNumber.text = countdown.ToString("0");
}
}
}
Comment
Your answer
Follow this Question
Related Questions
OnGUI doesn't update 1 Answer
Timer Board. 1 Answer
¿ How can I do a countdown timer showed in GUI that restarts in each scene ? 0 Answers
Having trouble moving a UI panel 1 Answer
converting timer countdown to only show minute and seconds 1 Answer