diff --git a/crates/bevy_math/src/bounding/raycast2d.rs b/crates/bevy_math/src/bounding/raycast2d.rs index e1def01936..c767c6e3fd 100644 --- a/crates/bevy_math/src/bounding/raycast2d.rs +++ b/crates/bevy_math/src/bounding/raycast2d.rs @@ -78,8 +78,8 @@ impl RayCast2d { pub fn circle_intersection_at(&self, circle: &BoundingCircle) -> Option { let offset = self.ray.origin - circle.center; let projected = offset.dot(*self.ray.direction); - let closest_point = offset - projected * *self.ray.direction; - let distance_squared = circle.radius().squared() - closest_point.length_squared(); + let cross = offset.perp_dot(*self.ray.direction); + let distance_squared = circle.radius().squared() - cross.squared(); if distance_squared < 0. || ops::copysign(projected.squared(), -projected) < -distance_squared {