Why can't I get clicked Sprite to act when it's a child?

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

Hi,

I have an Area2D as the top node in a scene with sprites as it’s children, which has this code:

func _on_Click_input_event(viewport, event, shape_idx):
if event is InputEventMouseButton:
if event.is_pressed():
do stuff

The function is connected to the input_event signal of the Area2D’s CollisionObject2D. This works fine when I run the scene on it’s own, but my main scene is a Node2D with the Area2D as a child and it doesn’t work.

Does anybody have any ideas?

Thank you.

:bust_in_silhouette: Reply From: Firty

I’m a little confused about your tree…
It turns out that area2D can overlap another area2D canceling the Input capture of the other. Or sometimes Control nodes can block the Input from the things below if the mouse option is in stop. Wouldn’t using ButtonTexture instead of area2D with sprite be a viable option?

Hi,
Good point, I’ll look into that and see if it helps.
Thanks!

powderblue042 | 2020-10-30 18:19

Yes, perfect!
Had some trouble with the Click Mask but got that figured out, worked like a dream.
I am one step closer to making the best game in history, I’ll give you a cut of the profits. :wink:
Thanks!

powderblue042 | 2020-11-01 02:51

:bust_in_silhouette: Reply From: larrxi

Set mouse_filter on your Node2D to pass.

Hi larrxl,
I’ve been looking into it and can’t quite find how to do this, could you explain further how to set this up? Also, how does this solve the issue? My research is helping, but I’m not sure exactly how this works.
I have found a solution, but would still like to know. :slight_smile:
Thanks for your help.

powderblue042 | 2020-11-01 02:48

Oops seems Node2D does not have mouse_filter but usually thats the problem.

larrxi | 2020-11-01 03:31