Time.timeScale equal to zero does not freezes my scene.

Hello Friends,

In my survival game the health bar value of the player continuously reduces with time. In the pause menu I have used Time.timescale = 0 to pause the game and creating a panel. The problem is, the panel is created but the health bar value in the background still reduces. This is a serious drawback for my game. Please help me with this. I will attach the script as well as the health bar so that you get a clear view of what’s happening.

void Start ()
PausePanel = GameObject.Find (“PanelForPause”);
PausePanel.gameObject.SetActive (false);

public void GamePaused()
	Time.timeScale = 0.0f;
	PausePanel.gameObject.SetActive (true);

Like other have said setting Time.timeScale to 0 will do exactly those things:

  • Time.time will stop and not increase any more.
  • Time.deltaTime will return 0
  • FixedUpdate is no longer being called.
  • Everything based on Time.time or Time.deltaTime will also freeze (for example WaitForSeconds in a coroutine)

Everything else will keep running. So if something still move / changes, you most likely do it wrong. If you used Time.deltaTime whereever you change something over time, that process should stop since Time.deltaTime will return 0.

You haven’t shown how your health bar is reduced. However if it still reduces when Time.timeScale is 0 you clearly doing it wrong.