0 votes

I have managed to use an event to allow a user to change keymappings as part of the menu. I have a saved config file and I want to make sure when the user logs in the changed key settings stay in place. To do this I have saved the scancodes of the keys selected as part of the event but I am having problems using the scancodes to change the key mappings the next time I log into the game.

Can anyone tell me how to either convert the scancode into a form that I can use to change the keymappings or else how to use the scancodes directly to do this?

Godot version 3.5
in Engine by (51 points)

As some context this is the code I have tried

scan_code = $"/root/GloVars".move_left
var new_k = InputEventKey.new()
new_k.set_scancode(scan_code)
InputMap.action_add_event("move_left", scan_code)

but it fails with the error

Invalid type in function "action add event" in base inputmap. Cannot convert arguement 2 from int to object

1 Answer

+1 vote
Best answer

Try changing

InputMap.action_add_event("move_left", scan_code)

to

InputMap.action_add_event("move_left", new_k)
by (2,001 points)
selected by

Oh thats embarrasing. Thank you it worked!

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.