Rebind more input under one Axis/Action mapping

Hello! I tried to make a blueprint system with help I can remap the keys under the Axis/ Action at runtime. For this, I used the Add/Remove Axis/Action mapping nodes. This work in a part, but after I added a new key the sequence of the keys is sort by alphabetically. Is there any solution for that or any idea how to do the rebinding with more keys under an Axis/Action mapping?

Built in nodes for mapping always will sort themselves. If you want to be able to remap keys in game you need to use your Input mappings set in Editor only as default keys (a reference).

You need then to create variables for your actual keys set to default at start and then through settings just change those variables and if you want to go back to defaults set the variables to values of Input mappings you create in Project Settings.
To save selected keys between sessions you need to create a SaveGame Object in which store your actual selected key values. Then just load them on GameInstance Object’s OnInit event (this way you will load them on game start) and save them every time you will change keys in your Settings in-game (and on shutdown to be safe).


So, I’ve set up a basic example for you.
You need to have this Blueprints: Player Controller, Save Game Object, Game Instance, User Widget.

Inside them implement this logic:

  • [YourPlayerController][1]
  • [YourGameInstance][2]
  • [YourOptionsWidget][3]

Some extra things you need to set up:

1. Action Mapping in your Project Settings with name you will use to get it. Remember! first (index 0) element of a Mapping is the last one shown in Project Settings;

291719-inputsettings.png


2. Variables inside GameInstance Blueprint: slot name (you may manually set it if you want) and SaveGame object; Remember to set the Slot value

291721-slot.png

291722-sgobject.png


3. Variables inside SaveGame Object (those will be the data you will save in .sav file, you don’t need to do anything else in SaveGame Object;

291723-savegameobject.png


4. Buttons and Input Key Selector inside your widget.


You can have as many mappings and keys in your mappings as you want, just for each Mapping create a variable inside SaveGame Object and set default values from corresponding mappings you’ve set in Project Settings. Also you need to handle it inside your Player Controller on EventTick.

For each key you want to change inside each of your mappings you need to have separate Input Key Selector in your widget.

If something is unclear, please ask below.

[All source files used in the example][8]

Hope this helps.

Thanks for the fast answer. To be honest this isn’t really understandable for me.


So first I have to do the basics this will be the Inputs in the Project settings. These binds will be the default keys values that I can refer to if I want to reset the binds if I understand correctly. But after this, I don’t know what to do. So could you give me an extended step by step description of the progress, please?

I would suggest you: [Full Project] Rama's UMG Rebindable Key System, Rebind keys at Runtime! - Community Content, Tools and Tutorials - Unreal Engine Forums

it is ready to use or you can pick it apart and look how it works.

I’ve updated the answer! Take a look.

Of course it would be better to split different things in different functions, but I think you can handle this on your own, this demonstration just has all you need in three Event Graphs.

Thank you! I checked it but unfortunately, I can only try to do just later.

For the Axis Mappings it works in similar way, just instead of modifiers (Shift, Control etc.) you need to set up an axis value for the given key.

Okay, I finally did the rebinds system. I don’t do the same as your solution, but your example was really helpful, and that led me to the best way to solve the problem. Thank you very much for your help!

No problem!