-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Stretch Mode 2D, Mouse Position scaled incorrectly #30950
Comments
I have the same issue with scale to viewport as well. Not only 2d. |
There is a way to get an "unscaled" coordinate by dividing it with some method with |
|
@Calinou could you please tell the method name and what you did? I'm curious if that would lead to a usable workaround in the meantime. |
@SGMcejo This seems to work: var unscaled_mouse_position = get_viewport().get_mouse_position() / get_viewport().get_size_override() * OS.window_size Test project (displays scaled and unscaled coordinates for comparison): test_mouse_coords.zip |
Hey, this issue has been bugging me for quite some time now, but I believe I I am neither experienced with the Engine's Source Code nor with the concept of all the transformations
stretch_transform: global_canvas_transform:
My solution to that was to get Viewport-Coordinates recursively: The Viewport-Coordinates of any sub-viewport
I had to create a new function to fix the issue of a viewport returning itself with node.get_viewport():
This works already even for nested sub-viewports if there is no transform set for any parent CanvasItem of a Viewport, and if
Now you can have a current camera in all Viewports and move it around without the coordinates being off. Note: All this time I only calculated viewport coordinates and not the global mouse coordinates. Only the transforms of parent CanvasItem's are not taken into account now. The issue is, Viewports don't have
To me it feels like this was never properly considered when the user got the ability to instance sub-viewports. https://drive.google.com/drive/folders/1uT-fp5XQuWakTOv8WjsQnRd3g70J9Ybs?usp=sharing |
@Sauermann has been looking into fixing various Viewport input issues in |
This is very difficult to tell for me, because I have not looked at the |
Godot version:
Release 3.1.1 (Latest)
OS/device including version:
Windows 10
Issue description:
My project is configured at the resolution 1600x900.
When the project is scaled up (I.E Fullscreen) the Viewport size is increased to 1920x1080. However, if the mouse is moved to the bottom right, the value is about 1600,900 (Actually around half a pixel less)
Note: If this is not a bug:
Documentation of Viewport states that the mouse position is relative to the viewport...
Steps to reproduce:
Make a brand new project, change the stretch mode to 2D.
Write a script that prints the mouse position.
Scale the window and check what the mouse position is claimed to be.
Minimal reproduction project:
Test.zip
The text was updated successfully, but these errors were encountered: