From c15592ec3fcbb9aa10082aa0adcfea5cfd2b3ca8 Mon Sep 17 00:00:00 2001 From: Franklin Date: Tue, 12 Sep 2023 12:03:32 -0400 Subject: [PATCH] Tweaked acceleration, speed, weight, gravity values and added momentum and inertia to jumps --- src/constants/player_values.rs | 11 +++-- src/logic/core/player/camera_effects.rs | 0 src/logic/core/player/mod.rs | 3 +- src/logic/core/player/player_movement.rs | 32 ++++++++------- src/logic/core/player/spawn_player.rs | 8 ++-- src/scenes/scene1/obstacles.rs | 51 ++++++++++++++++++++++-- 6 files changed, 79 insertions(+), 26 deletions(-) create mode 100644 src/logic/core/player/camera_effects.rs diff --git a/src/constants/player_values.rs b/src/constants/player_values.rs index 7de12c7..f70dcec 100644 --- a/src/constants/player_values.rs +++ b/src/constants/player_values.rs @@ -1,6 +1,11 @@ pub const MAX_LINEAR_PLAYER_VELOCITY: f32 = 10.0; -pub const PLAYER_ACCELERATION: f32 = 10.0; -pub const PLAYER_JUMP_FORCE: f32 = 1500.0; +pub const PLAYER_ACCELERATION: f32 = 12.0; +pub const PLAYER_JUMP_FORCE: f32 = 2500.0; /// Time in ms that player must be grounded in order to jump again -pub const PLAYER_JUMP_COOLDOWN_MS: u128 = 100; \ No newline at end of file +pub const PLAYER_JUMP_COOLDOWN_MS: u128 = 75; + +pub const PLAYER_SPRINT_SPEED_MULTIPLIER: f32 = 2.0; +pub const PLAYER_CROUCH_SPEED_MULTIPLIER: f32 = 0.25; + +pub const PLAYER_INITIAL_WEIGHT: f32 = 350.0; \ No newline at end of file diff --git a/src/logic/core/player/camera_effects.rs b/src/logic/core/player/camera_effects.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/logic/core/player/mod.rs b/src/logic/core/player/mod.rs index 8cbe426..5afdd06 100644 --- a/src/logic/core/player/mod.rs +++ b/src/logic/core/player/mod.rs @@ -1,4 +1,5 @@ pub mod player_movement; pub mod spawn_player; pub mod camera_player_sync; -pub mod player_vertical_sync; \ No newline at end of file +pub mod player_vertical_sync; +pub mod camera_effects; \ No newline at end of file diff --git a/src/logic/core/player/player_movement.rs b/src/logic/core/player/player_movement.rs index 4cabf68..bcd19e6 100644 --- a/src/logic/core/player/player_movement.rs +++ b/src/logic/core/player/player_movement.rs @@ -1,7 +1,7 @@ use bevy::prelude::*; use bevy_rapier3d::prelude::*; -use crate::{comps::core::markers::player::Player, constants::player_values::{MAX_LINEAR_PLAYER_VELOCITY, PLAYER_ACCELERATION, PLAYER_JUMP_COOLDOWN_MS, PLAYER_JUMP_FORCE}}; +use crate::{comps::core::markers::player::Player, constants::player_values::{MAX_LINEAR_PLAYER_VELOCITY, PLAYER_ACCELERATION, PLAYER_JUMP_COOLDOWN_MS, PLAYER_JUMP_FORCE, PLAYER_CROUCH_SPEED_MULTIPLIER, PLAYER_SPRINT_SPEED_MULTIPLIER}}; #[derive(Component)] pub enum PlayerLinearYState { @@ -59,31 +59,33 @@ pub struct PlayerMovementInput { pub fn move_player(player_movement_input: PlayerMovementInput, mut query: Query<(&mut Velocity, &mut ExternalImpulse, &mut PlayerLinearYState, &Transform), With>, time: Res