Leaning almost perfect
This commit is contained in:
parent
57a14812ee
commit
d961bfc6b3
|
@ -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;
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue