Enabling an action map on a succesful input from another action map gives inconsistent behavior.

For my project I've set up two action maps. One for player controls like movement and interaction, and one for when UI is up, like having the esc button close the window. On interaction (from actionmap A), I enable and subscribe a function to an action from actionmap B. Both these interactions use the 'E' button on the keyboard.

The very first time this happens, the action from actionmap B is immediatly triggered on subscribe, after I've essentialy pressed the 'E' button. Any subsequent time, this action is not triggered (which is what I would suspect to happen).

I've tried to debug it a bit, and it seems that in InputManager.cs, in FireStateChangeNotifications, the array of 'signals' can change from within NotifyControlStateChanged(), eventhough the comment would suggest otherwise. On the first occurence, the iteration is on index = 4, and it does come across the changed action map later in the for-loop. On any other occurence, the same function seems to be later in the for-loop, and does not come across the changed action.

The comment in question:

What is the expected behavior here? Is this what is supposed to happen? Or is this a bug?
I'd like to include the 'E' in my second action map, but this behavior is undesirable, and as far as I'm aware there doesn't seem to be an easy way to figure out of the input was triggered on the same update as the action map was enabled.


What version of the Input System are you using?

Also make sure Initial State Check is not checked on the action.

I can offer two work arounds.

Use cancelled instead of performed, that way when you switch to the UI map it isn't in the performed state. Of course your UI code would still need to use performed.

Second use a "Global" map that has the duplicate actions in it. If using PlayerInput and InputManager this might be more difficult as you have make sure that when you switch action maps that you enable the global one as it will get disabled.


I'm using version 1.4.1 on Unity 2021.3.9f1. The Initial State Check is not checked.

I appreciate the suggestions, but I've managed to work around it using a Coroutine. Instead of setting the callback when switching the ActionMaps, I start a Coroutine and wait till the end of the frame. After that, I can set the callback properly, as the previous signal of the duplicate key has been removed.

1 Like

Same issue in 1.5.1 with Unity 2022.3.0f1