In this basic scene, I'm finding that my Area2d
no longer fires the CollisionObject2d.input_event
as soon as I add a ColorRect
to the scene.

(Image preview doesnt seem to work - the URL is https://imgur.com/a/HItl3Qo )
So there's:
--> Node2d (root)
----> Area2d
------> CollisionShape2d
------> Sprite
----> ColorRect
I have a script on my ClickableArea2d
which is hooked up to the input_event
, so that when clicked, it prints to the console.
public void _on_ClickableArea2D_input_event(Viewport viewport, InputEvent inputEvent, Shape shape)
{
if (inputEvent is InputEventMouseButton mouseButton && mouseButton.Pressed)
{
GD.Print("Clicked");
}
}
If I toggle visibility off on my BackgroundColorRect
off, my ClickableArea2d
's input_event
fires and the message is logged to the console. However If I toggle visibility of the color rect back on, my clicks are no longer detected.
Can anyone suggest why this is happening, and how I might fix it? I essentially want the BackgroundColorRec
as a background only and not to intercept any clicks.
Edit
After some more searching, I found this helpful SO answer which explains the solution:
In the ColorRect, there is a "Mouse" section. Originally it was set to "stop". Change it to "Ignore" fixes the issue