diff --git a/src/camera.rs b/src/camera.rs index 2582901..ac1b20a 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -405,11 +405,12 @@ pub fn find_closest_target( // not on the player mesh but on the camera, which doesn't have a position. let (angular_diameter, angle, distance) = calc_angular_diameter_known_target_vector( trans, camera_transform, &target_vector); + let distance_to_surface = distance - trans.scale.x; if angle <= angular_diameter.clamp(0.001, PI) { // It's in the field of view! //commands.entity(entity).insert(IsTargeted); - if distance < closest_distance { - closest_distance = distance; + if distance_to_surface < closest_distance { + closest_distance = distance_to_surface; closest_entity = Some(entity); } }