-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Wrong mouse coordinates after window resize when using viewport stretch-mode canvas_items or viewport #52295
Comments
This bug does exist in v3.3 (and also v3.2 at the very least) but in a slightly different way... Steps to reproduce on 3.3:
Minimal project: I've had a longstanding issue with this and I could never figure out why it happened until I saw this ticket. It never occurred to me the problem may have been in the engine itself. So I started testing a couple things and thanks to @ZuBsPaCe, for posting this bug, I finally found a way to work around it properly in my project. :) |
I'm not fully sure if its the same issue or not, but I think this might also affect UI elements in godot 4. |
In 3.3.3-stable using a StretchShrink setting other than 1 on a ViewportContainer makes GetGlobalMousePosition() incorrect. If you set it back to 1 it works. For values higher than 1, the reported position appears to be offset by an amount that seems to scale with the screen scale. (Using Display->Window->Stretch Mode->Viewport.) My personal workaround. (C# version)
|
Related to #50802. |
Godot version
v4.0.dev (75697c0)
System information
Windows 10
Issue description
I want to position a Sprite2D at the global mouse position.
This works when setting stretch mode to disabled/keep-aspect, even when resizing the screen:
When I set stretch mode to canvas_items/keep-aspect, the mouse coordinates are sometimes wrong after I resize the window:
When I set stretch mode to viewport/keep-aspect, the mouse coordinates are always wrong after I resize the window:
Hints:
2d
orviewport
stretch mode does not scale mouse coordinates #34805 could be related. But it's in 3.2 and I'm not using ViewportContainer/Viewport at all.Steps to reproduce
Minimal reproduction project
ViewportScalingGodot4.zip
The text was updated successfully, but these errors were encountered: