Coding_Guy
Coding_Guy

Reputation: 151

How to check for mouse click on Area2D in Godot 4?

How do I detect mouse clicks/mouse events in an Area2D's script? Do I use the func _process(delta) function? Let's say I have an area 2D called area. So what should the script be like? I want something like this:

extends Area2D


func _process(delta):
    if mouse_touching && mouse_left_down:
        print("clicked on object")

Upvotes: 2

Views: 7297

Answers (1)

Theraot
Theraot

Reputation: 40295

If your Area2D has input_pickable then it will get a call to _input_event when the user clicks it.

Upvotes: 2

Related Questions