Advertisement Jump to content
  • Advertisement
  • entries
  • comments
  • views

Unreal Engine 4: Dynamically Changing Input Bindings



I have been working on a new game.  This one I'm going to be using mostly C++ in this one. I try to add something in each new game I work on that I haven't done before. This time its changing the input bindings at runtime. A lot of searching turn up a lot of old and not very useful information. So I figured I would provide a working way to do this without having to spend hours trying to find good and current information. So here it goes.

First the main class used for altering input bindings is UInputSettings. The key functions being RemoveAxisMapping, AddAxisMapping, RemoveActionMapping, AddActionMapping and SaveKeyMappings. We can create an instance of the class like this 

UInputSettings *Settings = const_cast<UInputSettings*>(GetDefault<UInputSettings>());

Then its easy to add or remove axis and action mappings. 

Settings->RemoveAxisMapping(FInputAxisKeyMapping(AxsName, FKey(*OldKey)));
Settings->AddAxisMapping(FInputAxisKeyMapping(AxsName, FKey(*NewKey)));

Settings->RemoveActionMapping(FInputAxisKeyMapping(AxsName, FKey(*OldKey)));
Settings->AddActionMapping(FInputAxisKeyMapping(AxsName, FKey(*NewKey)));

And when you're done just save the changes


Here is a function I am using to update an action mapping. You must remove the current mapping or both will exist. If the current key to jump is space and you change it to J, if you don't remove space the player can then hit either space or J to jump.

void USurvivalGameInstance::UpdateActionMapping(FName ActName, FString OldKey, FString NewKey)
    UInputSettings *Settings = const_cast<UInputSettings*>(GetDefault<UInputSettings>());
    if (!Settings) { return; }

    Settings->RemoveActionMapping(FInputActionKeyMapping(ActName, FKey(*OldKey)));
    Settings->AddActionMapping(FInputActionKeyMapping(ActName, FKey(*NewKey)));



Recommended Comments

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!