Rebinding keys no

How create a rebinding input keys system in blueprints; no using 's plugin.

What is in plugin, is not exposed to blueprint by default and you can do that only on C++, plugin primarly exposes feature not exposed to blueprint. But look on API refrence:

Set bind function is also command in console which oyu can call from blueprint

To create the setbind console command as above you need to create a class that can run console commands and be saved. Normally you would do this in the gameInstance class since it stays the entire game run-time.

The gameInstance class doesnt allow the ExecuteConsoleCommand node however.

So I suggest creating a blueprint interface with a function in it that called RunConsoleCommand with a stringinput “ConsoleCommand” that simply executes a console command in from that string with the “ExecuteConsoleCommand” node and it has to have a dummy return so just add a boolean output on the function and dont connect anything to it.

NExt in the blueprint interface add “GetSettingsInstance” which simply takes nothing in and outputs “gameSettings” (this will be a save game class you create next)

Then create a savegame class that saves all your key bindings.

Now take a class that the user will interact with and add the BPI and for the RunConsomeCommand under “Interfaces” on the left hand tool bar with the blue f simbol, input a string for setting the bind to whatever key and whatever your binding. You can then set that string with an append node to format it however you want and call it wherever to do those binds and it will be saved in your savegame class.

Then create a macro library that takes in an input executution pin, a string “saveGameFile” “saveUserIndex” int and a blueprintinterface (the one you created above) that loads a saved game file like SettingsSaveFile (in your savegameclass make it so it outputs a .sav file to /saved/savegames/ called something like MyGameSettingsFile) and outputs it to an execution pin and a gameSettings pin (save game class) and connect it to the EventInit() event node on your game instance and then promote the gameSettings output pin to a variable called game settings.

In your macro create one last macro called “GetGameSettings” that does exactly as it sounds, it takes in an input execution pin and an input for GameInstance (which you will always connect with a GetGameInstance node) and it outputs an output execution pin and a gameSettings output (your saved game class) it loads the save-game file or class from your savegameclass and then outputs gameSettings in the line earlier which you can bind to a variable like “savedSettings” in any class you want to load the saved bindings from. Make sure these macros are in amacro library so they can be called from any class.

Lastly make sure your either setting up a widget to call those bindings in the function that uses the RunConsoleCommand blueprint interface or you have them called in the class that has that interface added.

Any classses that you want to bind keys from, as well as your gameinstance will have to have that blueprint interface added.

Its a bit more complicated than that but that should get you started.

Don’t forget to accept an answer that best clears your question up or answers it so when the community finds your question in the future via search/google they know exactly what you did to fix it/get it going.

you can bind keys in blueprints, just make a data table that converts the Key’s display name into an integer, and use an array of integers to relate each index to a numbered function.

like this:

the CSV spreadsheet text would look like this:

"Name","ActionID"
"A",0
"B",1
"C",2
"D",3
"E",4
"F",5
etc... listing every input along with a unique number to identify it.

then you can create a blueprint struct with a single integer named ActionID, and use that to import the CSV as a data table.

rebinding a key is just changing the value of an integer in an array of integers. the index is the keyID, the value is the FunctionID.

since custom action events don’t show up when you press the AnyKey, you need to add them separately, with a macro similar to my MapKeyToAction, but instead of passing in a Key struct, you can pass in an IntegerID, and skip the datatable part. so in the event graph, you would hook up your custom action mapping events to the macro and pass in a literal int for the KeyID. the integer should be a number that is higher than the highest number on your data table, and each action mapping event should use consecutive IDs, so you don’t waste space in the array.

you can use the InputTable RowNames and ListOfActionNames to populate your menus with widgets, passing in the index from the ForEachLoop to set the index of each menu card. when you click on a card, you can use the index to determine what keyID to bind, and what ActionID to bind it to.

the custom action events would be bound similar to the V, B, and N keys in this image:

but the KeyID will be a much higher number so it doesn’t conflict with all the keys from the datatable.

More more thanks i am very grateffuly

Where i find the “call function by key id” and “punch,grab,ckick,open inventory” and “rebind key” functions?

those are all either macros or custom events, and all of them are shown in the images above.

Hey. I am late, but i was searching for this myself. I am making a simple Game just trying myself out here and there cause i am totally new to this.
My problem was that my GF uses an AZERTY Keyboard. but i figured out a workaround. Tho you might want to save the Booleans somewhere else, Im currently figuring out how to save it to a SaveGame file.

Heres my solution.

Home it helped! :slight_smile:

this has nothing to do with rebinding keys at runtime.

Have they added any new functionality since you posted this solution? It seems you’re completely bypassing the settings in Engine Input correct?

Blueprint still doesn’t have a way to bind key input dynamically, so without c++ this is still probably the best method using only blueprints.

with an array of integers, you can have a set of input numbers that map to a set of output numbers, and change that mapping dynamically by setting elements in the array. it works just like equipping items in an action adventure game: you have an item slot number for every input key, and you have an item ID number mapped to that item slot.

even if blueprint had custom functions for binding keys dynamically, i would still choose to use an array of integers instead, because its easy to debug, its efficient enough, its simple to understand, its easy to save the data, its easy to port it to another game engine, and there will never be a scenario where this technique is unavailable. this technique would work on a gameboy or a graphing calculator or a cell phone etc… it works in almost any programming language and will be compatible with any game engine.

I am trying to do this, but i cant figure it out what i have to enter in the “command” field in the execute console command to use “setbind” function, could you please make a pic or a example?. Ty in advance and sorry for the noob question.

Hello! Since Version 4.17 there is now a better, official way of rebinding keys with blueprints only!
please watch this video:

I know this is an old thread, but I think this might be helpful to someone :slight_smile:

Here mate, I made a simple project about this. For now only actions keys… but I am trying to improve it with Axis key also and a better way of handling the player settings without touching the defaults .Project

The project is for UE 4.22 . Hope this helps you.