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?

in Engine by (44 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.

by (1,377 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.

+1 vote

OK. I got the answer in the forum.

var ev = InputEventKey.new()
ev.scancode = KEY_A
InputMap.action_add_event("ui_a", ev)
by (44 points)
edited by
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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.