Topic was automatically imported from the old Question2Answer platform.
Asked By
d2clon
I am implementing a tutorial for my game. During the tutorial I want some of the InputEventActions to not have an effect until I have explained them.
I know I can play with Node.set_process_input ( bool enable ) (documentation). But this will disable all InputEventActions. I would like to only, temporarily, disable the “jump” InputAction for example.
The simple solution is to store the progress of the tutorial, and simply don’t process the jump action if it hasn’t been “gained” yet.
A more involved process is removing the input events associated with the input action at runtime, saving them in a variable, and re-adding them to the input action once the jump is gained.
You can use InputMap.action_get_events(<action_name>), InputMap.action_erase_events(), and InputMap.action_add_event(<action_name>, <event>).
It works as a charm:
var jump_input_events
func disable_jump():
jump_input_events = InputMap.action_get_events("jump")
InputMap.action_erase_events("jump")
func renable_jump():
for input_event in jump_input_events:
InputMap.action_add_event("jump", input_event)