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.