You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The viewport_to_world and viewport_to_world_2d functions take in viewport_position which is not relative to the screen corner. To get the correct viewport_position it has to be adjusted to the viewport logical position.
I don't think this should replace the current code on the page, but it would be helpful to have something that points in this direction as well. When using a crate like bevy_pixel_camera which modifies the viewport position it's not very straightforward with physical and logical viewport positions.
Here is a code snippet that takes the viewport logical position into account:
Page: Convert cursor to world coordinates - 2D games
The
viewport_to_world
andviewport_to_world_2d
functions take inviewport_position
which is not relative to the screen corner. To get the correctviewport_position
it has to be adjusted to the viewport logical position.I don't think this should replace the current code on the page, but it would be helpful to have something that points in this direction as well. When using a crate like bevy_pixel_camera which modifies the viewport position it's not very straightforward with physical and logical viewport positions.
Here is a code snippet that takes the viewport logical position into account:
The text was updated successfully, but these errors were encountered: