Enabling Initial State check on buttons shared across action map causes dynamic bitfield assert fail

I have a UI and a gameplay action map. Both gameplay map and UI have ESC button to toggle pause. In code I directly subscribe to action assets:

GameplayPauseAction.performed += gameplayState.Pause;
UIPauseAction.performed += pauseState.UnPause;

gameplayState.Pause; instantly changes the inputmap to UI. However, UIPauseAction then fires causing pauseState.UnPause. This results in the game going gamplay->Pause then returning back to gameplaystate despite pressing ESC once. From what I understand, InitialStateCheck is suppose to prevent this, not firing the event if the action map(UI map in this case) wasn’t active at the moment the button was pressed. However I get an error instead:


In DynamicBitField:

Am I doing something wrong? If so, what is the correct approach for handling buttons that are shared across mutually exclusive inputmaps?

I’m using playerinput to change action maps if it matters.

1 Like

(not the exact issue you’re describing, but a similar due to the same button input being read twice - hopefully still helps someone)

Crazy that no one has a solution to this. I’m running into the same issue. And it only happens the first time for me. It takes two “esc” presses to open the menu the first time and then on subsequent presses it works fine. Which is a mystery.

A way I found around it is:

    public void ShowMenu()
    {
        StartCoroutine(ShowMenuDelayed());
    }
    private IEnumerator ShowMenuDelayed()
    {
        yield return null;

        animator.SetBool(ANIMATOR_IS_SHOWING, true);
        playerInput.SwitchCurrentActionMap("UI");
        EventSystem.current.SetSelectedGameObject(menuButtons[0].gameObject);
        GameManager.instance.PauseGame();
    }

Basically because I was switching action maps and both action maps use “esc”, it got triggered twice on first press - THE FUCKING MYSTERY IS WHY DOES THIS HAPPEN ONLY THE FIRST TIME…

This works because my ShowMenu is called in one frame with “esc” and then the coroutine makes the action map switch in next frame, where the “esc” isn’t read a second time.