Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Superkrypet |
I wan’t to use an Area2D on the UI of my game but i don’t now how to interact with something on the canvas layer
What do you mean by “interact”? Do you have trouble getting the node? If so, how does your scene tree look like and which node holds the script in which you’re trying to get the node?
njamster | 2020-08-01 17:55
Quick example:
if i make a custom mouse with a sprite on and then hover it
over an Area2D(with body enterred signal)connected
to the canvaslayer. The Area2D will actually not detect it
Superkrypet | 2020-08-05 06:30
Basicly the area 2D node does not work
Superkrypet | 2020-08-05 06:31
if i make a custom mouse with a sprite on
Ambiguous! Do you mean you added a Sprite-node to the scene and let it follow the mouse cursor? Or are you talking about actually changing the mouse cursor?
hover it over an Area2D(with body enterred signal)connected to the canvaslayer.
You keep mentioning the term “CanvasLayer”. Are you talking about the default CanvasLayer which forms the root-node of the scene-tree or have you actually added additional ones to the tree? Also: How is that relevant here?
The Area2D will actually not detect it
Why should it? A Sprite-node is not a body, thus no body is entering the area. The body_entered
-signal will only trigger on a Kinematic-, Static- or RigidBody.
I still don’t get what’s your problem and where you need help…
njamster | 2020-08-05 21:05
you just helped me without helping me
the reason it did not work is because i used a sprite and body entered does not detect that. You just reminded me and now i know i have to change it to a different kind of node or another sort of code
Also i come from game maker where you usally have problems detecting the mouse on a UI layer.
thats the only reason i actually tried to attach a sprite to the mouse cursor as a workaround.
So if you still want to help me then how do i detect a mouse with an Area2D whitout attaching something to it because if i dont mistake the cursor is not a body
Superkrypet | 2020-08-06 18:58