edit: this sort of works... but it shouldn't be considered a perfect answer as it means you can't use the _input(event: InputEvent)
function. To make this properly work, the code must be put inside of _process()
, otherwise you will get unusual behaviour (given that the Input
Singleton only seems to update once per frame.)
In 3.5 it is possible to simply set the triggers as buttons and there will be no issue. However I am using 4.0 beta (5-16 so far) In the 4.0 beta, it seems that the best option is to do the following...
While InputEvent.is_action_pressed will be called multiple times,
Input.is_action_just_pressed will be called once.
So, instead of
func _input(event):
if event.is_action_pressed("action_name"):
do_something()
do the following
func _process():
if Input.is_action_just_pressed("action_name"):
do_something()