New Input System - Timescale Set To 0 - Input Controls don't work properly

Background Information:
Unity Build: 2019.4.16f1 | LTS
Input System: Version 1.0.2 | Release January 21, 2021

Hello everyone,

Problem: When the Pause Menu opens, and the time.timescale = 0, the menu element behaviour and the input controls are also scaled by the timescale to 0. I tested this by setting the value just to 0.1, and the time which had to pass was 10 times longer than before for an event to happen, e.g. button click answer or key pressed answer, in this case ESC.

I have the assumption, that the events that are talking to each other via the two classes mentioned below are somehow effected by the time.timescale reduction. But I have no clue, how to fix that in an elegant way. I already understood, that the execution of the Update() Method is not effected by the timecale, which I could confirm by placing a decent debug.Log() statement into one of them.

Classes:
MenuController : MonoBehaviour
InputController : MonoBehaviour

MenuController.cs

public class MenuController : MonoBehaviour
{

    public GameObject pauseMenuObject;

    public void OnPauseMenuStart(bool isPressed_Pause)
    {
        if (isPressed_Pause)
        {
            if (pauseMenuObject.activeSelf)
            {
                pauseMenuObject.SetActive(false);
                NormalizeGameSpeed();
            }
            else
            {
                pauseMenuObject.SetActive(true);
                PauseGame();
            }

        }
    }


    public void PauseGame()
    {
        Time.timeScale = 0.1f;
    }

    public void NormalizeGameSpeed()
    {
        Time.timeScale = 1.0f;
    }

}

InputController.cs

[Serializable]
public class OpenPauseMenuEvent : UnityEvent<bool> { }
public class InputController : MonoBehaviour
{
    public OpenPauseMenuEvent openPauseMenuEvent;

    private void Awake()
    {
           // Instantiate the Player1 controller class.
           controllerClassPlayer1 = new Player1_();
    }

    private void OnEnable()
    {
        controllerClassPlayer1.Gameplay.PauseGame.started += OnOpenPauseMenu;
        controllerClassPlayer1.Gameplay.PauseGame.canceled += OnOpenPauseMenu;

    }

    private void OnOpenPauseMenu(InputAction.CallbackContext context)
    {
        if (context.started)
        {
            openPauseMenuEvent.Invoke(context.started);        
          
        }
    }
}
1 Like

Hey everyone, I found the solution in the meanwhile.
If you are using the new input system go to:

#1:
EDIT → PROJECT SETTINGS → INPUT SYSTEM PACKAGE

#2:
Switch UPDATE MODE to: PROCESS EVENTS IN DYNAMIC UPDATE

Et voilĂ , it works =)

Another good help is the following discussion:

15 Likes

Holy crap this saved me, I can’t believe nobody touches on this in their “how to pause unity the right way with timescale” tutorials. Nuts.

2 Likes