Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Discussion Conflicting Action Maps for Keyboard Bindings?!

Discussion in 'Input System' started by aydin_khp, Oct 26, 2022.

  1. aydin_khp


    May 15, 2020
    The input system has just started to acting weird in my game, and I say "has just started" because it was working without problem till yesterday.

    I have two action maps (UI and Player) which have some shared bindings for Navigate/Move actions; For examples both of them are bound to Gamepad's Left Stick or both of them are bound to Keyboard's WASD. In the game scene I am listening to GameActions.Player.Move.performed event to move my character.

    The problem here is that the performed event never is not getting called at all anymore and as the result my game character won't move using A and W keys; The Gamepad is not affected by this problem though and it works without problem.

    Since the game was working perfectly before and I am directly working with the actions (and not through PlayerInput for example) I never thought it might have something to do with the UI action map; However out of despair I changed the binding to A in the UI Action Map to B and the performed event started to fire again thus the my character can move to the left using A now.

    Any one has any idea what is happening here? I am missing something in the recent updates?

    - Unity version: 2022.1.17f1
    - Input System version: 1.4.3
  2. You always need to have disambiguation on your input bindings. Which means you only should have one action for one binding key or whatever. In your case the most common used technique is simply enable/disable the bindings which shouldn't fire in the situation:
    - in gameplay: move bindings enabled, UI bindings disabled
    - when the UI is shown, you should have the move bindings disabled and the UI bindings enabled

    Enabling and disabling bindings is most simplest through their ActionMaps. So basically when you show the UI you disable the Player movement (or entire Player) action map (you supped to pause during UI tweaks I guess) and enable the UI action map, when you return to the gameplay, do the opposite and enable the player and disable the UI action map.

    This solves 99% of real game problems. In the unlikely scenario if you legitimately want to fire more than one action with the same bindings (avoid as much as possible), then you probably met with the change for supporting separate "B" and "SHIFT+B" binding. Hitting "SHIFT+B" won't fire action with binding "B", which means they do the disambiguation. And they decided for some reason to stop at first matching binding. If you really need multiple actions firing on the same binding at the same situation, then you can find a solution here:
    Last edited by a moderator: Nov 1, 2022
    aydin_khp likes this.
  3. aydin_khp


    May 15, 2020
    Thank you for the response. That's completely cleared out the situation for me. As the matter of fact, I didn't know that you can't have multiple actions with the same binding enabled at the same time; Now that I know it I would put it in my designs.

    I guess what happened here, that I made me face the issue now out of the blue, is that I kinda forced Unity to regenerate and build some older codes and libraries on that day which somehow changed the order in which the actions where registered; So I think before rebuilding the libraries, Player ActionMap bindings were registered before UI ActionMap (or the other way around) but after the built the order somehow got reversed (maybe because of the newer version of InputSystem).