Closed as duplicate of#18005
Description
Bevy version
0.16.0
What you did
Used sprite picking with custom viewport
Camera {
viewport: Some(Viewport {
physical_position: (window_size * 0.125).as_uvec2(),
physical_size: (window_size * 0.75).as_uvec2(),
..default()
}),
..default()
},
What went wrong
- pointer coordinate in sprite picking is incorrect. A sprite is picked in the wrong position.
Potential fix
Sprite picking code subtracts viewport min from cursor coordinate:
bevy/crates/bevy_sprite/src/picking_backend.rs
Lines 143 to 151 in cd67bac
However 2d_viewport_to_world example does not.
bevy/examples/2d/2d_viewport_to_world.rs
Lines 35 to 42 in cd67bac
If I remove the subtraction from sprite picking code as well, it seems to work correctly. (it is redundant as Camera::viewport_to_world
already does?)