![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Syl |
Thxs!
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Syl |
Thxs!
![]() |
Reply From: | pgregory |
Put it inside a KinematicBody2D
and set the pickable flag on the KinematicBody2D
.
Area2D doesn’t work? And what’s a pickable flag?
Syl | 2018-03-02 16:47
Not sure what you mean by Area2D, don’t know where that came from.
The general approach is to create a KinematicBody2D
as a container for the whole “clickable” thing, add a CollisionShape2D
to that, and set the shape, then add a script to the KinematicBody2D
to react to the clicks, and set the pickable
flag on the KinematicBod2D
in the Inspector. It should look something like this in the Scene panel:
Node2D
KinematicBody2D
CollisionShape2D
Sprite
And if you click the KinematicBody2D
and look in the Inspector panel, there is a section called “Pickable”, unfold that and there is a checkbox in there called “Pickable”, enable that and it should respond to mouse clicks through the _input(event)
function on your GDScript.
Note: Sorry, this site doesn’t support attachments, otherwise I’d attach a screengrab to show it better. Hope this helps.
pgregory | 2018-03-02 16:59
That’s help a lot, thxs as much! It would work with a collisionpolygon2D also, cause I have to set a circle for my clickable zone?
Syl | 2018-03-02 17:29
Should work with either CollisionShape2D
, for which you can assign a variety of different basic shapes, or CollisionPolygon2D
which you can define arbitrarily.
pgregory | 2018-03-02 17:41
Thxs a lot!
Syl | 2018-03-02 17:48