Created
September 6, 2022 14:52
-
-
Save hiulit/b093e5d6373aef2a8a3026db9aff5c9f to your computer and use it in GitHub Desktop.
Enable/disable input for the whole game/app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func disable_input(actions_allowed = []) -> void: | |
for action in InputMap.get_actions(): | |
# Allow some input actions. | |
if action in actions_allowed: | |
continue | |
# Remove the action and its events. | |
InputMap.action_erase_events(action) | |
InputMap.erase_action(action) | |
# To avoid the error: The InputMap action "xxx" doesn't exist. | |
InputMap.add_action(action) | |
func enable_input() -> void: | |
InputMap.load_from_globals() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example of allowing some input actions: