Topic was automatically imported from the old Question2Answer platform.
Asked By
ashish
Hi,
The following code
func _input(event):
# If the user press a mouse button
if event.type == InputEvent.MOUSE_BUTTON and event.pressed:
if event.button_index == BUTTON_LEFT:
Gives throws the following error:
Invalid get index ‘type’ (on base: ‘InputEventMouseMotion’).
Place that outside the rest of the statement, though, because otherwise godot will try and check if moving the mouse is pressed, which doesn’t work
func input(event):
# If the user press a mouse button
if event is InputEventMouseButton:
if event.pressed:
if event.buttonindex == BUTTONLEFT
if event is InputEventMouseButton and event.pressed and event.buttonindex == BUTTONLEFT:
print("this works too! because it only checks the second if the first true etc")