From bfad39613e40e9f86a4efa626a0ad53d55b21d80 Mon Sep 17 00:00:00 2001 From: yuni Date: Thu, 23 May 2024 00:59:33 +0200 Subject: [PATCH] better value for "up" vector --- src/actor.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/actor.rs b/src/actor.rs index d3738ce..1be6464 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -563,6 +563,7 @@ fn handle_wants_lookat( mut query: Query<( &Position, &mut Rotation, + &Transform, &mut ExternalTorque, &WantsToLookAt, )>, @@ -576,7 +577,7 @@ fn handle_wants_lookat( return; }; - for (pos, mut rot, mut _torque, target_id) in &mut query { + for (pos, mut rot, trans, mut _torque, target_id) in &mut query { let target_pos = if target_id.0 == cmd::ID_SPECIAL_PLAYERCAM { player_pos } else if let Some(target_pos) = id2pos.0.get(&target_id.0) { @@ -584,7 +585,7 @@ fn handle_wants_lookat( } else { continue; }; - rot.0 = look_at_quat(**pos, *target_pos, DVec3::Y); + rot.0 = look_at_quat(**pos, *target_pos, trans.up().as_dvec3()); } }