Stop first person bounce in air

This commit is contained in:
timokoesters 2020-03-17 16:01:12 +01:00
parent b9f6dfac77
commit 08b44db1fc

View File

@ -174,26 +174,27 @@ impl Scene {
gamma: f32,
) {
// Get player position.
let player_pos = scene_data
.state
.ecs()
let ecs = scene_data.state.ecs();
let player_pos = ecs
.read_storage::<comp::Pos>()
.get(scene_data.player_entity)
.map_or(Vec3::zero(), |pos| pos.0);
let player_rolling = scene_data
.state
.ecs()
let player_rolling = ecs
.read_storage::<comp::CharacterState>()
.get(scene_data.player_entity)
.map_or(false, |cs| cs.is_dodge());
let player_running = scene_data
.state
.ecs()
let is_running = ecs
.read_storage::<comp::Vel>()
.get(scene_data.player_entity)
.map_or(false, |v| v.0.magnitude_squared() > 0.5);
.map(|v| v.0.magnitude_squared() > 0.5);
let on_ground = ecs
.read_storage::<comp::PhysicsState>()
.get(scene_data.player_entity)
.map(|p| p.on_ground);
let player_scale = match scene_data
.state
@ -219,7 +220,7 @@ impl Scene {
CameraMode::FirstPerson => {
if player_rolling {
player_scale * 0.8
} else if player_running {
} else if is_running.unwrap_or(false) && on_ground.unwrap_or(false) {
player_scale * 1.6 + (scene_data.state.get_time() as f32 * 17.0).sin() * 0.05
} else {
player_scale * 1.6