How to let Enhanced Input flow down to lower priority context if not triggered

Like said in the title, is it possible to have 2 different contexts (with different priorities), both having an action bound to the same Key (in my case left mouse button), but having the lower priority action triggering ONLY when the upper one doesn’t ?

Atm, if the higher priority context consumes the input, it will NEVER flow down to the lower priority one. But if it doesn’t consume it, both may activate at the same time if conditions are met.

Or do I need to add/remove contexts (/inputs) in those particular cases ? Since we have access to the PlayerController in InputTrigger and such I think it’s doable, but it doesn’t seem that clean…

1 Like

I managed to create a workaround, which is to change the InputAction bConsumeInput value to true when the Action Started, and to set it back to false when Completed.

You just need to call this function :

UEnhancedInputLibrary::RequestRebuildControlMappingsUsingContext(MappingContext, true);

in order to reflect the changes made to the InputAction, otherwise it won’t be effective.

The bool (set to true here) is to force the update on current frame or not. If not, the lower priority Contexts will get the Input for 1 frame, which may be problematic (it is in my case).

It’s not ideal, since you have to manually add this logic for all InputAction facing the same problem, but it does its job atm.

If one day someone found a cleaner way to do this (the ideal would be a boolean like bConsumeInput, but just in when Action is triggered), feel free to post it here (or put a link to this post if it’s closed, I would be grateful :slight_smile: )

I found one caveat with this “solution”.

If you had some Action Triggering/Ongoing and change the consumption of the Input (from the higher priority Context), the Completed and/or Canceled Event of those Actions will NOT fire.

At least when rebuilding control mappings on the same frame, dunno what happens if you let the current frame as it is.