Collision Shape 2D not detecting mouse properly

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mymokol

A collision shape that is a child of an Area2D node is not detecting the mouse properly - the area2d is supposed to perform an action whenever the mouse enters and exits the collision shape. There are two collision shape children of the aera2d node. When i hover the mouse above the first one, it works flawlessly. The second one, though, only activates when you hover over a specific area on the edge of the collision shape, instead of the whole collision shape as it is supposed to. I’ve encountered this problem before, but with a button control node, where the solution was to set the mouse filter to mouse filter ignore, however it doesn’t appear to be a possibility here in an area2d and a collision shape.

:bust_in_silhouette: Reply From: Whalesstate

if the 2 collisions intersects then passing from one collision to another one inside the intersections will not emit signal entered because area treats both of them as one big collision , you need to go out both collisions and then go back to the second one , you can enable visible collision shapes from the debug menu to see the collisions inside the game

They do not intersect, in fact they’re on opposite sides of the screen. It does not in fact intersect with any collision shape whatsoever. The CollisionShape doesn’t work wherever the mouse enters from.

mymokol | 2021-02-26 06:49

for me it works fine and it checks for mouse in both collisions , I’m sure there’s a control node that blocks the mouse from reaching the other collision , try to open a new 2d scene and make a new test and it will work fine

func _ready() -> void:
	connect('mouse_entered', self, '_on_mouse_enter')

func _on_mouse_enter():
	print('entered')

Whalesstate | 2021-02-26 06:56

True, I do have a rich text label in the same spot as the nonfunctional collision shape. I tried to write a bit in the _ready() function that lists through the children and if a child is a richtextlabel, it sets its mouse_filter to MOUSE_FILTER_IGNORE and it actually worked. Thanks for your help! : )

mymokol | 2021-02-26 07:40