How to repeat an event while mouse button is pressed, and the mouse isn't moving?

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

Hi,

I want to set an event that will happen while the mouse left button is being pressed, and held down. I’ve tried this, but it doesn’t work, it only recognizes when I’m moving the mouse, and not when I’m holding it down, while not moving it.

func _input(event):
	if Input.is_action_pressed("click"):
		print("a")

Is there a better way to do that?

:bust_in_silhouette: Reply From: Jowan-Spooner
func _ready():
    set_process(true)
func _process(delta):
    if Input.is_mouse_button_pressed(BUTTON_LEFT):
        print("a")

Your problem is that the mouse click isn’t an action that will activate the _input() function.

Haven’t tested it but should work.