How do i detect when the mouse is over only the front most object in a scene with overlapping area2d objects?

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

Hi. I have a scene with a ysort node with multiple characters as children. The characters have an area2d attached to detect if the mouse is over them. currently if any part of two characters overlap and i mouse over that part the mouse over event propagates to both characters.
How do i stop the mouse over event at the front most character?
I’ve tried using get_tree().set_input_as_handled() in the _on_Area2D_mouse_entered() function and in unhandled_input() but it doesn’t seem to do anything. I’ve searched around but i can’t seem to find a straightforward answer to this question. Please help. Thanks.

The reason you can’t stop the mouse over event is because it’s two different mouse over events. And unhandled_input() won’t stop the mouse over event, only stuff listed in the project settings input map. Not sure how to only mouse over one character, though, sorry.

exuin | 2020-09-19 19:43

thanks anyway. thats still good info. i appreciate the reply.

BusterDublup | 2020-09-19 21:46