diff --git a/Readme.md b/Readme.md index 8bb70fc..45e597a 100644 --- a/Readme.md +++ b/Readme.md @@ -4,7 +4,7 @@ - [x] ~~Glitch: Fall does not remove linear damping, only after jump~~ - [x] ~~Glitch: Negative linear damping on jump allows for bunny hopping~~ -- [ ] Feature: Add smooth camera movement to camera on crouch. Right now it's too fast and looks arcade af. +- [x] Feature: Add smooth camera movement to camera on crouch. Right now it's too fast and looks arcade af. - [ ] Feature: Add jump effect to camera - [ ] Feature: Add Stamina (with bar?) - [ ] Feature: Subtle Headbob, FOV change on movement (Distinguish between sprinting and walking). diff --git a/src/comps/core/controller.rs b/src/comps/core/controller.rs index 1258e35..b5897c1 100644 --- a/src/comps/core/controller.rs +++ b/src/comps/core/controller.rs @@ -41,7 +41,7 @@ pub fn capture_input( ]) { let player_movement_input = PlayerMovementInput { up: keyboard_input.just_pressed(KeyCode::Space), - down: keyboard_input.pressed(KeyCode::C), + down: keyboard_input.just_pressed(KeyCode::C), left: keyboard_input.pressed(KeyCode::A), right: keyboard_input.pressed(KeyCode::D), front: keyboard_input.pressed(KeyCode::W), diff --git a/src/constants/player_values.rs b/src/constants/player_values.rs index 943f06e..60554ab 100644 --- a/src/constants/player_values.rs +++ b/src/constants/player_values.rs @@ -8,9 +8,10 @@ pub const PLAYER_CROUCH_SPEED_MULTIPLIER: f32 = 0.25; pub const PLAYER_INITIAL_WEIGHT: f32 = 75.0; pub const PLAYER_GRAVITY_SCALE: f32 = 4.0; -pub const PLAYER_HEIGHT: f32 = 2.0; +pub const PLAYER_HEIGHT: f32 = 2.5; pub const PLAYER_CAMERA_HEIGHT: f32 = 1.0; pub const PLAYER_CROUCH_HEIGHT: f32 = 0.0; +pub const PLAYER_CROUCH_TIME_MS: u128 = 130; pub const PLAYER_LINEAR_DAMPING: f32 = 3.5; pub const PLAYER_LINEAR_DAMPING_WHILE_JUMPING: f32 = 0.25; diff --git a/src/logic/core/player/camera_player_sync.rs b/src/logic/core/player/camera_player_sync.rs index 0fd26ee..8482380 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::*}; use crate::{ comps::core::{camera::MainCamera, markers::player::Player}, - constants::player_values::{PLAYER_CAMERA_HEIGHT, PLAYER_CROUCH_HEIGHT}, + constants::player_values::{PLAYER_CAMERA_HEIGHT, PLAYER_CROUCH_HEIGHT, PLAYER_CROUCH_TIME_MS}, }; use super::player_movement::PlayerLinearXZState; @@ -28,13 +28,21 @@ impl Default for MouseMovementSettings { pub fn sync_camera_to_player( mut player: Query<(&mut Transform, &PlayerLinearXZState), (With, Without)>, mut camera: Query<&mut Transform, (With, Without)>, + time: Res