0 votes

Area2D is set to pickable, signal is connected, yet it never receives any event (handler is never called).

Scene hierarchy: root -> Node2D -> CanvasLayer -> ColorRect -> CenterContainer -> MarginContainer -> Panel -> Panel

Button in a same container (last Panel) works, so I guess nothing else is eating events?

Docs are not helpful at all:

If no one wanted the event so far, and a Camera is assigned to the Viewport, a ray to the physics world (in the ray direction from the click) will be cast. If this ray hits an object, it will call the CollisionObject.inputevent() function in the relevant physics object (bodies receive this callback by default, but areas do not. This can be configured through Area properties).

Which property? Is this true for Area2D as well? There is no mention of "event" on a whole Area2D page. How can I tell if my main (and only) Camera is attached to a viewport (I don't see anything resembling viewport connection in root nor Camera)? Maybe something is stealing the event, but I have no idea how to debug that. I read in other question about setting mouse filter to ignore on root or parent container, that didn't do anything.

Any tips would be appreciated.


Edit1: I also tried simpler case with root -> Node2D -> CanvasLayer -> ColorRect and no instancing from code. I still didn't manage to get it working. I tried changing z-index, mouse filter property on all parents (where it's available) and made sure Area2D is in one collision layer (some issues on GitHub suggested it's required), but nothing helped.

in Engine by (135 points)
edited by

1 Answer

0 votes
Best answer

I got it fixed by converting ColorRect into Node2D and recreated it inside this new node. I also had to set all containers and panels which were behind the Area2D to have mouse filter = ignore.

Setting ColorRect's mouse filter to ignore didn't work when it was a root of the scene (so when Area2D was its indirect child).

by (135 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.