Avoid mouse echo

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

My scene has a button connected with a pressed() signal:

func _on_new_game_pressed():
    emit_signal("new_game")

The game has only this action, that is the mouse click (actually touchscreen because it is a mobile game). The new_game does not change the scene, it just clears the screen and reset the points.

The issue I’m facing is that when new_game runs, it starts firing up the shoot action.

func get_input():
    var m_input = Input.is_action_just_pressed("ui_shoot)
    if m_input:
        shoot()

func _physics_process(delta):
    get_input()

How can I prevent this from happening?

:bust_in_silhouette: Reply From: andersmmg

You could either use a short delay before the game starts and resets. If that’s the only button that has the problem, you could also have a variable that is set to false when you click the button and the button function will check the variable to ignore just the first click.