From 521491d3a61901ab056234e96f6446517b68eac1 Mon Sep 17 00:00:00 2001 From: Franklin Date: Thu, 23 Nov 2023 09:49:26 -0400 Subject: [PATCH] Gimball lock problem --- Design.md | 7 ++++--- src/logic/core/player/camera_player_sync.rs | 7 ++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Design.md b/Design.md index 8c21fa6..ed2b842 100644 --- a/Design.md +++ b/Design.md @@ -18,9 +18,10 @@ Multiplayer # TODOs: - [x] Detach player rotation from character model - - [ ] Weapon Sway - - [ ] Fixing leaning - - [ ] Snap back leaning too quick + - [ ] Weapon Sway PENDING!!! + - [x] Fixing leaning + - [x] Snap back leaning too quick + - [ ] Issue with moving around quickly - [ ] Bring Crouching back - [ ] Inspect animation (procedural) - [ ] Reload animation (procedural) diff --git a/src/logic/core/player/camera_player_sync.rs b/src/logic/core/player/camera_player_sync.rs index 3a34fb7..ed82fa1 100644 --- a/src/logic/core/player/camera_player_sync.rs +++ b/src/logic/core/player/camera_player_sync.rs @@ -122,8 +122,6 @@ pub fn follow_cursor_with_camera( if window.cursor.grab_mode != CursorGrabMode::None { for mut player_transform in player_query.iter_mut() { - - for mut camera_transform in camera_query.iter_mut() { let (mut yaw, mut pitch) = (player_transform.rotation.to_euler(EulerRot::YXZ).0, camera_transform.rotation.to_euler(EulerRot::YXZ).1) ; for motion in motions.read() { @@ -177,14 +175,13 @@ pub fn follow_cursor_with_camera( new_rot.1 = eulers.1; player_transform.rotation = Quat::from_euler(EulerRot::XYZ, new_rot.0, new_rot.1, new_rot.2); } else { - let mut eulers = desired_rotation_quat_player.to_euler(EulerRot::XYZ); - eulers.2 = eulers.2 + 0.0f32.to_radians(); let mut new_rot = player_transform.rotation.lerp( - Quat::from_euler(EulerRot::XYZ, eulers.0, eulers.1, eulers.2), + Quat::from_rotation_z(0.0), time.delta_seconds() / player_values_state.player_lean_time, ).to_euler(EulerRot::XYZ); new_rot.1 = eulers.1; + player_transform.rotation = Quat::from_euler(EulerRot::XYZ, new_rot.0, new_rot.1, new_rot.2); } }