diff --git a/crates/bevy_sprite/src/picking_backend.rs b/crates/bevy_sprite/src/picking_backend.rs index ad2afc33d1..b367efcc00 100644 --- a/crates/bevy_sprite/src/picking_backend.rs +++ b/crates/bevy_sprite/src/picking_backend.rs @@ -71,8 +71,13 @@ pub fn sprite_picking( continue; }; - let Ok(cursor_ray_world) = camera.viewport_to_world(cam_transform, location.position) - else { + let viewport_pos = camera + .logical_viewport_rect() + .map(|v| v.min) + .unwrap_or_default(); + let pos_in_viewport = location.position - viewport_pos; + + let Ok(cursor_ray_world) = camera.viewport_to_world(cam_transform, pos_in_viewport) else { continue; }; let cursor_ray_len = cam_ortho.far - cam_ortho.near;