better aiming in 3rd person mode

This commit is contained in:
yuni 2024-05-08 18:40:01 +02:00
parent 500f5c7953
commit c2ee7ee3e1

View file

@ -151,14 +151,16 @@ pub fn sync_camera_to_player(
let (actor, player_transform) = q_playercam.get_single().unwrap();
// Rotation
camera_transform.rotation = player_transform.rotation * Quat::from_array([0.0, -1.0, 0.0, 0.0]);
let rotation = player_transform.rotation * Quat::from_array([0.0, -1.0, 0.0, 0.0]);
// Translation
if settings.third_person {
camera_transform.translation = player_transform.translation + camera_transform.rotation * (actor.camdistance * Vec3::new(0.0, 0.2, 1.0));
camera_transform.translation = player_transform.translation + rotation * (actor.camdistance * Vec3::new(0.0, 0.2, 1.0));
camera_transform.rotation = rotation * Quat::from_euler(EulerRot::XYZ, -0.02, 0.0, 0.0);
}
else {
camera_transform.translation = player_transform.translation;
camera_transform.rotation = rotation;
}
}