From c2ee7ee3e16e8226575ab9047eced9ee8d1f426c Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 8 May 2024 18:40:01 +0200 Subject: [PATCH] better aiming in 3rd person mode --- src/camera.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/camera.rs b/src/camera.rs index 22cba50..5b8d726 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -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; } }