Area2d doesn't work properly if child is moved

Godot Version

4.3.5

Question

(Issue depicted in linked video)
I have an area2d with 2 collisionshape2d children, one of which is supposed to move around to the location of a different UI element. What’s supposed to happen is when the mouse cursor is outside of the area it hides the element, but instead this behavior only occurs if the collisionshape2d is in the same general location it was when it started.

Both of the collision shapes visible in the video are a child of the same area2d, which are in turn a child of a Control node.

Code that updates the shape’s location:
collision_shape_destroy.position.y = destroy.position.y + 11.5 collision_shape_destroy.position.x = destroy.position.x + 52

Code that hides the UI when the cursor exits the area (connected to the area’s mouse_exited signal):
func _on_area_mouse_exited():
destroy.visible = false

No other code is relevant to this problem, I’ve already checked.

Video of exactly what’s happening

I highly recommend you use controls for the UI input detection.

How come you move an area2D’s collision shape over the the “Destroy” control to check for “mouse” events rather than control’s own mouse exited event?

Besides that, can you expand on what the desired behavior? What is this system you are creating?

I had no idea the control node had that feature, switching over to that instead instantly solved my problem so thank you!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.