Fixed bugs with movement system

This commit is contained in:
Franklin 2023-09-13 10:36:25 -04:00
parent 165e71f1c9
commit 664c5dd120
4 changed files with 6 additions and 3 deletions

View File

@ -1,3 +1,5 @@
# Experimental game # Experimental game
- [ ] Skybox - [x] Skybox
- [x] Glitch: Fall does not remove linear damping, only after jump
- [x] Glitch: Negative linear damping on jump allows for bunny hopping

Binary file not shown.

View File

@ -13,7 +13,7 @@ pub const PLAYER_CAMERA_HEIGHT: f32 = 1.0;
pub const PLAYER_CROUCH_HEIGHT: f32 = 0.0; pub const PLAYER_CROUCH_HEIGHT: f32 = 0.0;
pub const PLAYER_LINEAR_DAMPING: f32 = 3.5; pub const PLAYER_LINEAR_DAMPING: f32 = 3.5;
pub const PLAYER_LINEAR_DAMPING_WHILE_JUMPING: f32 = -0.5; pub const PLAYER_LINEAR_DAMPING_WHILE_JUMPING: f32 = 0.25;
pub const PLAYER_LATERAL_ACCELERATION_WHILE_SPRINTING_MULTIPLIER: f32 = 0.2; pub const PLAYER_LATERAL_ACCELERATION_WHILE_SPRINTING_MULTIPLIER: f32 = 0.2;
pub const PLAYER_LATERAL_ACCELERATION_MULTIPLIER: f32 = 1.0; pub const PLAYER_LATERAL_ACCELERATION_MULTIPLIER: f32 = 1.0;

View File

@ -1,7 +1,7 @@
use bevy::prelude::*; use bevy::prelude::*;
use bevy_rapier3d::prelude::*; use bevy_rapier3d::prelude::*;
use crate::{comps::core::markers::player::Player, constants::player_values::{PLAYER_LINEAR_DAMPING, PLAYER_JUMP_COOLDOWN_MS, PLAYER_LINEAR_DAMPING_TIME_OFFSET_AFTER_JUMP_IN_MS}}; use crate::{comps::core::markers::player::Player, constants::player_values::{PLAYER_LINEAR_DAMPING, PLAYER_JUMP_COOLDOWN_MS, PLAYER_LINEAR_DAMPING_TIME_OFFSET_AFTER_JUMP_IN_MS, PLAYER_LINEAR_DAMPING_WHILE_JUMPING}};
use super::player_movement::PlayerLinearYState; use super::player_movement::PlayerLinearYState;
@ -13,6 +13,7 @@ pub fn sync_player_y_state(
for (player_velocity, mut player_linear_y_state, mut player_damping) in &mut query { for (player_velocity, mut player_linear_y_state, mut player_damping) in &mut query {
if player_velocity.linvel.y < -1.0 { if player_velocity.linvel.y < -1.0 {
*player_linear_y_state = PlayerLinearYState::Falling; *player_linear_y_state = PlayerLinearYState::Falling;
*player_damping = Damping { linear_damping: PLAYER_LINEAR_DAMPING_WHILE_JUMPING, ..Default::default() };
} else if player_velocity.linvel.y >= -1.0 && player_velocity.linvel.y <= 1.0 { } else if player_velocity.linvel.y >= -1.0 && player_velocity.linvel.y <= 1.0 {
let previous_grounded_time = match *player_linear_y_state { let previous_grounded_time = match *player_linear_y_state {
PlayerLinearYState::Grounded(grounded_for) => grounded_for, PlayerLinearYState::Grounded(grounded_for) => grounded_for,