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 6 days ago in Engine by DogeMassaji (20 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 6 days ago by Xrayez (70 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 5 days ago by DogeMassaji (20 points)
edited 4 days ago 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.