better value for "up" vector

This commit is contained in:
yuni 2024-05-23 00:59:33 +02:00
parent e9afeefb7d
commit bfad39613e

View file

@ -563,6 +563,7 @@ fn handle_wants_lookat(
mut query: Query<( mut query: Query<(
&Position, &Position,
&mut Rotation, &mut Rotation,
&Transform,
&mut ExternalTorque, &mut ExternalTorque,
&WantsToLookAt, &WantsToLookAt,
)>, )>,
@ -576,7 +577,7 @@ fn handle_wants_lookat(
return; 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 { let target_pos = if target_id.0 == cmd::ID_SPECIAL_PLAYERCAM {
player_pos player_pos
} else if let Some(target_pos) = id2pos.0.get(&target_id.0) { } else if let Some(target_pos) = id2pos.0.get(&target_id.0) {
@ -584,7 +585,7 @@ fn handle_wants_lookat(
} else { } else {
continue; continue;
}; };
rot.0 = look_at_quat(**pos, *target_pos, DVec3::Y); rot.0 = look_at_quat(**pos, *target_pos, trans.up().as_dvec3());
} }
} }