I’m trying to implement controller UI navigation in my game, testing with a Dualshock 4 controller, but there’s a problem where sometimes my inputs happen twice, or even thrice.
For example, when you select the “start” button in the main menu, it’s supposed to take you to the character select screen and create an option for every character entry in the dictionary. But sometimes, seemingly at random, it creates each option twice, or even thrice.
Another example, when selecting the settings, it goes to the settings screen and immediately selects the first focused option.
This is the code I have on my menu button script:
if Input.is_action_pressed("confirm") and not event.is_echo():
if mouse_over && can_be_selected :
print("confirm input")
emit_signal("button_selected", button_type)
It prints “confirm input” sometimes once, sometimes twice, and sometimes thrice. I’ve tried using is_action_just_pressed, is_action_pressed, with and without not event.is_echo(), but the result is always the same.
And this has also happened once with mouse inputs, but only one time in my entire playtest history.
What’s the problem here? Is it a Godot problem, or a problem with my controller? If it’s a controller problem, how can I failsafe my game against double inputs? Any help is appreciated.
The problem is likely a bug in your code. Post the entire script.
Also make sure you’re not running the same script on multiple nodes. Put print(get_path()) right beside `print(“confirm input”) to check if it’s coming from the same node.