Correctly calculate direction and distance with yaws.

This commit is contained in:
Nolan Darilek 2022-08-04 14:30:07 -05:00
parent 1fcec80e0e
commit e1a1522269

View File

@ -493,15 +493,13 @@ impl GlobalTransformExt for GlobalTransform {
) -> String {
use bevy::math::Vec3Swizzles;
let scale = PHYSICS_SCALE.read().unwrap();
let (_, rotation, _) = self.to_scale_rotation_translation();
let pos1 = Isometry::new(
(self.translation() / *scale).xy().into(),
rotation.to_scaled_axis().z,
self.yaw().radians(),
);
let (_, other_rotation, _) = self.to_scale_rotation_translation();
let pos2 = Isometry::new(
(other.translation() / *scale).xy().into(),
other_rotation.to_scaled_axis().z,
other.yaw().radians(),
);
let closest =
closest_points(&pos1, &*collider.raw, &pos2, &*other_collider.raw, f32::MAX).unwrap();