+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.

asked Jan 27, 2018 in Engine by Patrick (17 points)

1 Answer

+3 votes

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.

answered Jan 27, 2018 by rolfpancake (1,006 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 How to use this Q&A? before posting your first questions.