diff --git a/crates/shared/src/ai/mod.rs b/crates/shared/src/ai/mod.rs index 8c1b69c..3e1188e 100644 --- a/crates/shared/src/ai/mod.rs +++ b/crates/shared/src/ai/mod.rs @@ -127,7 +127,7 @@ fn rotate(agent: Query<(Entity, &Engage)>, mut transform: Query<&mut Transform>) }; // Get the direction vector from the current position to the target - let direction = (target_pos - agent_transform.translation).normalize(); + let direction = (agent_transform.translation - target_pos).normalize(); // Project the direction onto the XZ plane by zeroing out the Y component let xz_direction = Vec3::new(direction.x, 0.0, direction.z).normalize(); diff --git a/crates/shared/src/aim/mod.rs b/crates/shared/src/aim/mod.rs index 3275a60..56991fc 100644 --- a/crates/shared/src/aim/mod.rs +++ b/crates/shared/src/aim/mod.rs @@ -146,7 +146,7 @@ fn update_npc_aim( let mut target_distance = f32::MAX; for (e, t) in potential_targets.iter() { - let delta = pos - t.translation; + let delta = t.translation - pos; let distance = delta.length();