Type-specific Input Action Mapping

I’m trying to decide on the most graceful way to handle a design decision regarding type-specific input action bindings.

At run-time, a player is able to change which pawn they are currently in control of and there is a hierarchy of various pawn types which each need to provide their own action mappings specific to their own type and players need to be able to customize their own keybinds to these mappings. The best way to describe it would be Input action map hot-swapping.

There’s some great ideas in the community for rebinding input action mappings at run-time within the wiki/forums and here on answerhub but I haven’t encountered any reference material on this specific requirement yet.

I’m trying to find a graceful way to do this while keeping performance in mind. The only feasible solution I’ve been able to come up with so far is to store separate configs for each required type in a special directory and, during game initialization, read each of these files and cache them in an array of input action maps. Then when a player possesses a new pawn where a swap is needed, the map would be grabbed from the cached array and assigned to the current settings.

Am I looking in the right direction here or anyone have a nicer way to do this?

I should mention, this is all planned to be handled in c++ only but I would prefer solutions where the mappings are accessible from blueprints for the sake of user keybind UI’s similar to the examples found within the community.

Sounds like a good way to go, thank you. I still may take a stab at caching each mapping when reading to cut back on IO reads and implement a little something to keep the config in-sync with any player-made changes at runtime.

Thank you again :slight_smile:

I tried using this method and found while I could clear Action bindings, Axis bindings wouldn’t work the same way :frowning:

What I ended up doing was essentially looking at the MovementMode at the start of each function (eg MoveForward) and returning if it didn’t match the desired mode.
Then I simply configured the same keys to various different actions.
:slight_smile: