The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

Using If Input.isactionpressed() does not work for me for some reason. It results in just one input as opposed to a continuous one.

I want to know how I would be able to detect holding input.

in Engine by (58 points)

1 Answer

+1 vote

As mentioned in this answer, it may be better to use the function Input.is_mouse_buttoned_pressed( mouse_number ) for detecting mouse clicks and when they're held down. In the _process() function:

func _process( some_change ):
    if Input.is_mouse_button_pressed( 1 ): # Left click
          # Perform some stuff.

In the _input() function:

var mouse_left_down: bool = false
func _input( event ):
    if event is InputEventMouseButton:
          if event.button_index == 1 and event.is_pressed():
                mouse_left_down = true
         elif event.button_index == 1 and not event.is_pressed():
                mouse_left_down = false
func _process( some_change ):
    if mouse_left_down:
                # Perform some stuff.

If you didn't know, when using Input.is_action_pressed( some_action ), it's usually used in the _process() function because it detects the input each frame.

Hope that helps.

by (3,164 points)
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 Frequently asked questions and 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 [email protected] with your username.