![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | lavaduder |
Okay what I am doing is setting up a controls menu. Where the player can change the InputMap’s actions. Example:
func _input(event):
InputMap.action_add_event("ui_accept",event)
if event.is_action("ui_accept"):
print(InputMap.get_action_list("ui_accept"))
I also want a preset menu where gdscript manually creates InputEvents. How ever I can’t find out how to do that in gdscript. I’ve tried doing this, but KEY_W is only an int not an actually InputEvent.
func _on_create_preset_input_pressed():
var new_input = KEY_W
InputMap.add_action("move_up")
InputMap.action_add_event("move_up",new_input)`
(SIDE NOTE) What is up with my formatting? i used /`/ why are tabs not showing properly?
lavaduder | 2019-01-02 13:54
for formatting multiline code correctly you have to leave a blank line and write everything with 4 blank spaces indentation extra. Something like this:
(blank line)
(four spaces)func _process(delta):
(four spaces)(four spaces) print(“hola”)
will render like this
func _process(delta):
print("hola")
p7f | 2019-01-02 14:08
Thank you. Now If only my real question was solved.
lavaduder | 2019-01-02 14:12
hi, i have a question… is only the seccond part what is not working? i mean, this?
func _on_create_preset_input_pressed():
var new_input = KEY_W
InputMap.add_action("move_up")
InputMap.action_add_event("move_up",new_input)`
p7f | 2019-01-02 14:49
Yes. _on_create_preset_input_pressed()
lavaduder | 2019-01-02 15:00
I posted an answer with the code you should use. It works for me.
p7f | 2019-01-02 15:17
Oh, i see you already found the answer.
p7f | 2019-01-02 15:45