Godot Version
4.2 stable mono official
Question
I’m porting my game from 3.5 to 4.2 and everything is working fine except for one (big) problem: I render my game in a Viewport in 3.5, and many of the objects in my game have Area2D’s attached to them to detect mouse hovers and clicks. So I’ve always faced this issue of how to pass the input through the viewport.
What ended up working for me in 3.5 was
- On the Viewport, mark it for Object Picking: Yes
- In the Viewport’s parent, a Control, mark it Filter: Pass
- In the Viewport’s parent, a Control, add the following code:
public override void _Input(InputEvent @event) {
base._Input(@event);
GetViewport()._UnhandledInput(@event);
GetNode<Viewport>("viewport")._UnhandledInput(@event);
}
This isn’t working in 4.2. According to the debugger, no one is detecting any clicks when I click in the space represented by t he parent Control / the Viewport under it.
What’s the right way to get Area2Ds and other things to receive input events when inside a Viewport in Godot 4.2?