public void TogglePauseGame()
{
if (isPaused)
{
isPaused = false;
}
else
{
isPaused = true;
}
}
When I fire the TogglePauseGame function, the debug.log works fine… but the timeScale just isn’t working for me… Does anyone know what I might be missing here?
I am using the new UI. I have a UI pause button that is calling the function onClick. I have change the code a bit:
public void pauseGame(){
TogglePauseGame();
if (isPaused)
{
Time.timeScale = 0f; // Sets the game time to zero
PausedMenu.SetActive(true); //Sets the pausedPanel to visible.
Controls.SetActive(false); // Sets the controls to invisible.
}
else if (!isPaused)
{
Time.timeScale = 1f; // Sets the gameplay speed to unpaused.
PausedMenu.SetActive(false); // Sets the pausedPanel to invisible.
Controls.SetActive(true); // Sets the touch controls to visible.
}
}
When I tap the UI Pause button it is calling the pauseGame() function (that way it is changing the bool each time it’s clicked) . But for some reason or other it still isn’t pausing the game, but it is showing the pause menu, so I know that the function is working…
I have a game over screen that is fired with an OnTriggerEnter2D, which I am using the exact same code as above on and the Time.TmeScale works fine with that. I’m wondering if it has something to do with the UI?
I have heard some while ago that you cannot set the timescale value to a complete 0! i don’t know if that is what’s causing your problems??? maybe try to set the timescale value to 0.00001f or even lower if possible it never Hurts to try it out
Did you fix it Oatz? I figured out what the problem was. I think it’s something to do with the time.timescale being called in the update method. That’s what my problem was anyway.