Area2D not detecting input through SubViewport Push_Input

Godot Version

Godot v4.3

Question

I have an Node2D called CameraIcon with two Sprite2Ds and an Area2D with a simple rectangle CollisionShape2D. The goal is to be able to click them or hover them to change which sprite is displayed. When I run just the 2D scene I am able to click and fire the event just fine but when it is in a SubViewport it seems to eat the input and not even fire the event.

I downloaded the “GUI in 3D Viewport” demo from the Godot engine asset library and that provided me with the math and methods to pass coordinates through events when the SubViewport is mapped to a ViewportTexture on a mesh by using an Area3D. The Control nodes all function correctly but I have yet to get Area2D nodes to respond using this formula.

The SubViewport has the following enabled:

  • Physics > Object Picking
  • Handle Input Locally
  • GUID > Embded Subwindows

Is there something I am doing incorrectly or is this not possible in Godot?

My code:
gui_in_3d.gd pastebin
Area3D signal:

I have just tried to receive physics-picking input events in an Area2D node in the SubViewport of the demo project and I was able to do so.
So it is likely, that there needs to be an adjustment made in your project files, but I didn’t see any obvious problem in your screenshot.

One of the problems, people experience in these situations, is that a Control-node takes precedence for handling input events, so perhaps you also have a Control node in the SubViewport, which has as mouse_filter either of the values Pass or Stop.
If you could share your project file, it would be easier to pinpoint the problem.

1 Like

Thank you for responding.
I took a look and found that mouse_filter was set to pass, but changing it to ignore still did not fix the issue.

I have uploaded my project to github

Hopefully the answer is clear once you see it

1 Like

Short answer:

This is a bug in the demo project.

Update your script to:

func _mouse_entered_area() -> void:
	is_mouse_inside = true
	node_viewport.notification(NOTIFICATION_VP_MOUSE_ENTER) # this line is new


func _mouse_exited_area() -> void:
	node_viewport.notification(NOTIFICATION_VP_MOUSE_EXIT) # this line is new
	is_mouse_inside = false

Long answer:

I didn’t experience the problem previously, because I tested it with Godot 4.2., but your issue is related to a change, that was done for Godot 4.3.
So I have created an update for the Demo project: Fix physics picking in Gui in 3D Demo by Sauermann · Pull Request #1139 · godotengine/godot-demo-projects · GitHub

Thank you for reporting this bug and providing a reproduction project to identify and fix it!

1 Like

That did the trick!
Thank you so much!