+1 vote

How can I identify a click event on a particular Node2D in Godot 3? I have some simple code that draws a circle and I want to run code when that circle is clicked.

extends Node2D

func _ready():
    # Called every time the node is added to the scene.
    # Initialization here
    pass

func _draw():
    # part of the CanvasItem class
    draw_circle(Vector2(0,0), 20, Color(1,1,1))

Thanks.

in Engine by (18 points)

1 Answer

+1 vote

Use its own _input-method and ask for a InputEventMouseButton event.

You can find some explanaition here:

In the godot demo projects you can find a lot of code implementing such behaviour.

by (1,036 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.