0 votes

How can I edit my InputMap with code? I cannot see any examples in the doc.Or there is some examples which I missed?

asked Jul 10 in Engine by DogeMassaji (34 points)

2 Answers

0 votes

Never used it but I think it'll go like this:

func _ready():
    InputMap.action_add_event("my_action", event)

See InputMap singleton documentation for other methods on how to modify input map.

answered Jul 10 by Xrayez (673 points)

Thank you. But what I confused in is how to set an InputEvent binding a key like "KEY_A" so that when I press the "A" key it can feedback the action Input.is_action_pressed("A").
Here is the Input singleton of the document:

var ev = InputEventAction.new()
ev.set_as_action("move_left", true)

Still not understand how to do it.

0 votes

OK. I got the answer in the forum.

var ev = InputEventKey.new()
ev.scancode = KEY_A
InputMap.action_add_event("ui_a", ev)
answered Jul 11 by DogeMassaji (34 points)
edited Jul 12 by DogeMassaji
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.