_process is_action_just_pressed triggered twice

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mvdtinkerer


I’m trying to detect a single keypress with the is_action_just_pressed command but it triggers twice.
Is there any way that I can trigger it only once?
I’ve also tried to disable the autoload script but it didn’t make any difference.

Here is the code:

func _process(delta):
if Input.is_action_just_pressed("right"):
	print("action RIGHT is pressed")

And this is what it returns:

action RIGHT is pressed
action RIGHT is pressed

It is likely that the code is being called twice, I would say. Are you sure that the script does not exist two or more in the scene?

toxicvgl | 2022-10-12 13:20

That may be the case, but is there a way that I can see if a script exists multiple times in the scene?

mvdtinkerer | 2022-10-12 13:24

I am not sure what the best way to debug is, but how about adding a line to print their node names?

toxicvgl | 2022-10-12 13:30

I’ll try that when I get home, thanks for your advice.

mvdtinkerer | 2022-10-12 15:55

:bust_in_silhouette: Reply From: godot_dev_

Add print("HelloWorld") to the _ready function of your script. If it’s called twice, there is your issue, you have 2 scripts and hence the _process is called twice