-
-
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
Tilemap in a nested viewport in a project with scaling enabled, offsets the position of the mouse #32222
Comments
Isn't it the same as #30950? |
Not sure, this affects only nested viewports (using the root viewport works fine, unlike in that bug report) and the suggested workaround in the comments doesn't seem to work for me. |
It does seem to be similar to #30215 though |
To avoid getting hit by godotengine/godot#32222 I had to add a workaround Also adapted the function comments according to the standards
I can confirm that the workaround mentioned in #30215 works for me as well Putting the following code as the mouse position, fixes the variable offset. Although I do believe that get_local_mouse_position should always report the true mouse position autoscaled to the viewport.
|
i can attest to this as well. my work around I believe is different to others.
|
Looks like my workaround stops working when the zoom level of the nested viewport changes. I need to see if I can tweak it further by taking the zoom level into account manually. EDIT: Workaround for the above
|
Thank you so much for this workaround! |
Godot version:
3.1.1
OS/device including version:
PC/Fedora Linux 30 (but seems to affect everything)
Issue description:
When you have a project where scaling is enabled and you have a tilemap within a viewport (i.e. not in the root viewport), the methods to return the mouse position start getting offset by a variable amount. The offset increases the further the mouse travels to the bottom-right. The offset also changes depending on the viewport zoom level.
Steps to reproduce:
You will see that the location of the mouse cursor, will not correspond to the cell your mouse is actually over. It's easier to see if you put a sprite to display the cell.
If you move the tilemap to have Node2D as the parent, the position will start working correctly. If you disable scaling in the project properties, it will also fix this issue.
I have also tried get_global_mouse_position() and others positioning options.
I also tried multiplying with various Transform2D objects during testing with no success.
Minimal reproduction project:
https://drive.google.com/file/d/1zUo4lsBz5Bn7MsgRhJcuCBg26qHxMJur/view?usp=sharing
The text was updated successfully, but these errors were encountered: