0 votes

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?

in Engine by (87 points)
edited by

1 Answer

0 votes
Best answer
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.

by (788 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.