diff --git a/src/constants/player_values.rs b/src/constants/player_values.rs index 34d4634..804e81a 100644 --- a/src/constants/player_values.rs +++ b/src/constants/player_values.rs @@ -18,6 +18,9 @@ pub const PLAYER_CROUCH_TIME_S: f32 = 1.25; pub const PLAYER_LINEAR_DAMPING: f32 = 3.5; pub const PLAYER_LINEAR_DAMPING_WHILE_JUMPING: f32 = 0.25; +pub const PLAYER_LEAN_TIME: f32 = 0.3; +pub const PLAYER_LEAN_ANGLE: f32 = 30.0; + pub const PLAYER_LATERAL_ACCELERATION_WHILE_SPRINTING_MULTIPLIER: f32 = 0.2; pub const PLAYER_LATERAL_ACCELERATION_MULTIPLIER: f32 = 1.0; diff --git a/src/logic/core/player/camera_player_sync.rs b/src/logic/core/player/camera_player_sync.rs index 59014c2..c98e7bf 100644 --- a/src/logic/core/player/camera_player_sync.rs +++ b/src/logic/core/player/camera_player_sync.rs @@ -3,7 +3,7 @@ use bevy::{input::mouse::MouseMotion, prelude::*, window::CursorGrabMode}; use crate::{ comps::core::markers::{camera::MainCamera, player::Player}, - constants::player_values::{PLAYER_CAMERA_HEIGHT, PLAYER_CROUCH_HEIGHT, PLAYER_CROUCH_TIME_S}, + constants::player_values::{PLAYER_CAMERA_HEIGHT, PLAYER_CROUCH_HEIGHT, PLAYER_CROUCH_TIME_S, PLAYER_LEAN_TIME, PLAYER_LEAN_ANGLE}, utils::rad_deg::radians_from_degrees, }; @@ -120,28 +120,28 @@ pub fn follow_cursor_with_camera( let right = Vec3::new(local_z.z, camera_transform.translation.y, -local_z.x); player_transform.rotation = desired_rotation_quat; if keyboard_input.pressed(KeyCode::Q) { - let final_quat = Quat::from_axis_angle(Vec3::Z, radians_from_degrees(30.0)); + let final_quat = Quat::from_axis_angle(Vec3::Z, radians_from_degrees(PLAYER_LEAN_ANGLE)); camera_transform.rotation = camera_transform .rotation - .lerp(final_quat, time.delta_seconds() / 0.2); - camera_transform.translation = camera_transform.translation.lerp(Vec3 { x: -right.x, y: camera_transform.translation.y, z: -right.z }, time.delta_seconds() / 0.2); + .lerp(final_quat, time.delta_seconds() / PLAYER_LEAN_TIME); + camera_transform.translation = camera_transform.translation.lerp(Vec3 { x: -right.x, y: camera_transform.translation.y, z: -right.z }, time.delta_seconds() / PLAYER_LEAN_TIME); } else if keyboard_input.pressed(KeyCode::E) { let final_quat = - Quat::from_axis_angle(Vec3::Z, radians_from_degrees(-30.0)); + Quat::from_axis_angle(Vec3::Z, radians_from_degrees(-PLAYER_LEAN_ANGLE)); camera_transform.rotation = camera_transform .rotation - .lerp(final_quat, time.delta_seconds() / 0.2); - camera_transform.translation = camera_transform.translation.lerp(Vec3 { x: right.x, y: camera_transform.translation.y, z: right.z }, time.delta_seconds() / 0.2); + .lerp(final_quat, time.delta_seconds() / PLAYER_LEAN_TIME); + camera_transform.translation = camera_transform.translation.lerp(Vec3 { x: right.x, y: camera_transform.translation.y, z: right.z }, time.delta_seconds() / PLAYER_LEAN_TIME); } else { camera_transform.rotation = camera_transform .rotation - .lerp(Quat::default(), time.delta_seconds() / 0.2); + .lerp(Quat::default(), time.delta_seconds() / PLAYER_LEAN_TIME); camera_transform.translation = camera_transform.translation.lerp(Vec3 { x: 0.0, y: camera_transform.translation.y, z: 0.0, - }, time.delta_seconds() / 0.2); + }, time.delta_seconds() / PLAYER_LEAN_TIME); } // headbob_camera(&mut camera_transform, time.delta_seconds_f64()); }