How to specifically rebind one control to one button?

Godot Version

4.2

Question

Currently the button for jumping in my game is Space, but I want to have a signal change that input to F in order to mess with the player in a joke level. How do I make a piece of code that specifically binds Jump to f?

My jump action is called “Jump”

I’ve been using InputMap.action_add_event() and InputMap.action_erase_event() but it asks for an InputEvent and I can’t find any way to make the InputEvent specifically say that it’s the F key.

Some help would be appreciated !

You can check the input_mapping demo here godot-demo-projects/gui/input_mapping at master · godotengine/godot-demo-projects · GitHub where it shows you how to do that.

It basically this part of the code godot-demo-projects/gui/input_mapping/ActionRemapButton.gd at master · godotengine/godot-demo-projects · GitHub

To create an InputEventKey as the event you just need to do something like:

var event = InputEventKey.new()
event.keycode = KEY_F
Input.action_add_event("jump", event)

thanks a lot!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.