How to make CollisionObject2D pickable on multiple viewport?

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


I have main scene structure like this:


On main’s _ready functions, I made sure that P2Viewport world’s equal to P1Viewport world so both viewport render the same game world (multiviewport setup). ObjectPool basically contains CollisionObject2D that implement _input_event function to detect whether the object clicked or not. While it works on single viewport, I can’t make it works on my multiviewport setup. Could someone help me with this particular problem?


I’m trying to understand your problem. The ObjectPool can detect clicks from the PV1Viewport, yet they can’t be detected from the PV2Viewport?

Ertain | 2019-10-10 19:28

ObjectPool can detect click normally on root viewport, but on setup like above it can’t detect any click on P1Viewport and P2Viewport.

not_available | 2019-10-10 23:46

I think I’ve had this problem before. One of the nodes could be intercepting the clicks. Have you tried setting the Mouse filter to “ignore” for the Control nodes?

Ertain | 2019-10-11 01:03

I tried to change mouse filter on HBoxContainer, P1ViewportContainer, and P2ViewportContainer to “ignore” but that didn’t work. I also tried “pass” but that also didn’t work. Aside from that I also set physics_object_picking to true on P1Viewport and P2Viewport but that also didn’t work.

not_available | 2019-10-11 06:41