- Home /
Question by
sameraii007 · Jul 04, 2017 at 03:45 PM ·
pause menutime.timescale
Time.Timescale = 0 in two different places, But there's a delay.
I have Time.Timescale =0 in two different place. One "Pause" at time of death, another "pause" is opening the menu. Timescale = 0 works for both, individually. However, if the player dies, and then you open or close the menu, it "un-pauses" for about 3 or 4 secs, then "pauses" again. Why the delay? I have the pause/open&close menu on a toggle. Don't think the code for pause at death is the problem. Here is the code for the toggle:
if (Time.timeScale == 0)
Time.timeScale = 1;
else
Time.timeScale = 0;
Comment
Answer by merkaba48 · Jul 04, 2017 at 07:07 PM
If you die, the timescale is 0, and then you open a menu, won't that set timescale back to 1 again?
Answer by Vollmondum · Jul 04, 2017 at 08:09 PM
var dead: boolean;
var pause: boolean;
function Update()
{
if(dead)
{
pause = false;
}
if(!dead && !pause)
{
Time.timeScale = 1.0; // unless you have some slomo
}
else
{
Time.timeScale = 0.0;
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612125514im_/https://answers.unity.com/themes/thub/images/avi.jpg)