Unity3D Time.timeScale = 0 not working
I am trying to pause my game using Time.timeScale = 0; but in debug I can see it change the the value to 0 but still my game is not in freeze state. I call this function on Pause button press.
public void pause_button_click()
{
resume_window.SetActive(true);
Time.timeScale = 0;
Debug.Log(Time.timeScale);
}
Answer by rafaelrivera · Jul 15, 2018 at 07:41 PM
I had a problem with time.timescale. My pause screen was alright but then it stopped working. It happened to be that I imported some asset with scripts and these scripts have Time.timeScale set to 1 on Start(). Just fixed it. If anyone having the same problem, just look through your new assets scripts and try to find Time.timeScale there. Hope that helps. Bye.
Answer by brent9 · Jun 24, 2017 at 10:24 AM
The Update method is always called every frame and changing Time.timeScale does not affect the invocation of the Update method. It does scale the Time.deltaTime and Time.fixedDeltaTime, meaning that the speed of invocation of the FixedUpdate method is affected by the Time.timeScale.
I would recommend checking if code is either in fixedUpdate (for physics) or if it uses the Time.deltaTime.
source: https://docs.unity3d.com/ScriptReference/Time-timeScale.html
I hope this helps your (and perhaps others) problem.