Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node2D inside a SubViewport returning (0, 0) from get_mouse_position() #72807

Closed
rbarongr opened this issue Feb 6, 2023 · 1 comment · Fixed by #71768
Closed

Node2D inside a SubViewport returning (0, 0) from get_mouse_position() #72807

rbarongr opened this issue Feb 6, 2023 · 1 comment · Fixed by #71768

Comments

@rbarongr
Copy link

rbarongr commented Feb 6, 2023

Godot version

v4.0.beta17.official [c400205]

System information

macOS 13.0.1

Issue description

When a Control node is over a SubViewportContainer (with a SubViewport as a child), both in Full Rect anchors, asking for the get_viewport().get_mouse_position() from a scene inside the SubViewport returns (0, 0) as the position of the mouse.

This wasn't happening in at least Beta 15. I was getting the mouse position without any problems before Beta 17. I didn't try Beta 16.

Steps to reproduce

  1. Create a Control node
  2. Add two children: A SubViewportContainer and a Control node
  3. Put both in Full Rect anchors so the Control node (child) is covering the SubViewportContainer
  4. Ask for the get_viewport().get_mouse_position() from inside a scene of the SubViewport

As you can see in this screenshot: asking for the mouse position from inside the Node2D script always returns (0, 0).

SubViewportContainerIssue

Only If the Control (child) mouse filtering is set to Ignore you can get the mouse position. But with that you are losing the mouse inputs from that Control node.

You can find the setup of these nodes in the MRP.

Minimal reproduction project

Run the main scene (control.tscn) and move the mouse around the screen. Look for the print in the Output tab.

SubViewportMousePositionIssue.zip

@Sauermann
Copy link
Contributor

Sauermann commented Feb 6, 2023

Sounds similar to #60390 which happened long before beta 15, so this isn't an exact duplicate.
Can confirm the bug on Linux since v4.0.beta16.official [518b9e5].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants