From 8064b51ee28e988ce1188d8f4b3953af49b8479f Mon Sep 17 00:00:00 2001 From: timokoesters Date: Fri, 17 Jan 2020 21:08:27 +0100 Subject: [PATCH] improvement: better movement --- common/src/state.rs | 2 +- common/src/sys/controller.rs | 2 +- common/src/sys/movement.rs | 15 +++++---------- common/src/sys/phys.rs | 5 +++-- common/src/sys/stats.rs | 2 +- server/src/lib.rs | 4 ++-- 6 files changed, 13 insertions(+), 17 deletions(-) diff --git a/common/src/state.rs b/common/src/state.rs index a111a5f1fa..4bbaa5d3b4 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -39,7 +39,7 @@ pub struct DeltaTime(pub f32); /// upper limit. If delta time exceeds this value, the game's physics will begin to produce time /// lag. Ideally, we'd avoid such a situation. const MAX_DELTA_TIME: f32 = 1.0; -const HUMANOID_JUMP_ACCEL: f32 = 16.0; +const HUMANOID_JUMP_ACCEL: f32 = 26.0; #[derive(Default)] pub struct BlockChange { diff --git a/common/src/sys/controller.rs b/common/src/sys/controller.rs index b5b48aa2fa..86e468b45c 100644 --- a/common/src/sys/controller.rs +++ b/common/src/sys/controller.rs @@ -16,7 +16,7 @@ use specs::{ use std::time::Duration; use vek::*; -const CHARGE_COST: i32 = 50; +const CHARGE_COST: i32 = 200; /// # Controller System /// #### Responsible for validating controller inputs and setting new Character States diff --git a/common/src/sys/movement.rs b/common/src/sys/movement.rs index 5a96f68496..e7c93e3bbf 100644 --- a/common/src/sys/movement.rs +++ b/common/src/sys/movement.rs @@ -15,13 +15,13 @@ use vek::*; pub const ROLL_DURATION: Duration = Duration::from_millis(600); -const HUMANOID_ACCEL: f32 = 50.0; +const HUMANOID_ACCEL: f32 = 100.0; const HUMANOID_SPEED: f32 = 120.0; -const HUMANOID_AIR_ACCEL: f32 = 10.0; +const HUMANOID_AIR_ACCEL: f32 = 15.0; const HUMANOID_AIR_SPEED: f32 = 100.0; const HUMANOID_WATER_ACCEL: f32 = 70.0; const HUMANOID_WATER_SPEED: f32 = 120.0; -const HUMANOID_CLIMB_ACCEL: f32 = 5.0; +const HUMANOID_CLIMB_ACCEL: f32 = 10.0; const ROLL_SPEED: f32 = 17.0; const CHARGE_SPEED: f32 = 20.0; const GLIDE_ACCEL: f32 = 15.0; @@ -221,14 +221,9 @@ impl<'a> System<'a> for Sys { if inputs.climb_down.is_pressed() && !inputs.climb.is_pressed() { vel.0 -= dt.0 * vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 6.0); } else if inputs.climb.is_pressed() && !inputs.climb_down.is_pressed() { - vel.0.z = (vel.0.z + dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED); + vel.0.z = (vel.0.z + dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED).max(0.0); } else { - vel.0.z = vel.0.z + dt.0 * GRAVITY * 1.5; - vel.0 = Lerp::lerp( - vel.0, - Vec3::zero(), - 30.0 * dt.0 / (1.0 - vel.0.z.min(0.0) * 5.0), - ); + vel.0.z = (vel.0.z - dt.0 * GRAVITY * 0.01).min(CLIMB_SPEED); } } diff --git a/common/src/sys/phys.rs b/common/src/sys/phys.rs index 955d229c22..e974fca9e4 100644 --- a/common/src/sys/phys.rs +++ b/common/src/sys/phys.rs @@ -11,14 +11,14 @@ use { vek::*, }; -pub const GRAVITY: f32 = 9.81 * 4.0; +pub const GRAVITY: f32 = 9.81 * 7.0; const BOUYANCY: f32 = 0.0; // Friction values used for linear damping. They are unitless quantities. The // value of these quantities must be between zero and one. They represent the // amount an object will slow down within 1/60th of a second. Eg. if the frction // is 0.01, and the speed is 1.0, then after 1/60th of a second the speed will // be 0.99. after 1 second the speed will be 0.54, which is 0.99 ^ 60. -const FRIC_GROUND: f32 = 0.08; +const FRIC_GROUND: f32 = 0.15; const FRIC_AIR: f32 = 0.0125; const FRIC_FLUID: f32 = 0.2; @@ -275,6 +275,7 @@ impl<'a> System<'a> for Sys { { // ...block-hop! pos.0.z = (pos.0.z + 0.1).ceil(); + vel.0.z = 0.0; on_ground = true; break; } else { diff --git a/common/src/sys/stats.rs b/common/src/sys/stats.rs index b877a85759..b013a12171 100644 --- a/common/src/sys/stats.rs +++ b/common/src/sys/stats.rs @@ -5,7 +5,7 @@ use crate::{ }; use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage}; -const ENERGY_REGEN_ACCEL: f32 = 1.0; +const ENERGY_REGEN_ACCEL: f32 = 0.5; /// This system kills players, levels them up, and regenerates energy. pub struct Sys; diff --git a/server/src/lib.rs b/server/src/lib.rs index 6bf0557244..797e0f52f8 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -258,7 +258,7 @@ impl Server { state.write_component(entity, body); state.write_component(entity, comp::Stats::new(name, main)); - state.write_component(entity, comp::Energy::new(200)); + state.write_component(entity, comp::Energy::new(1000)); state.write_component(entity, comp::Controller::default()); state.write_component(entity, comp::Pos(spawn_point)); state.write_component(entity, comp::Vel(Vec3::zero())); @@ -1185,7 +1185,7 @@ impl StateExt for State { .with(comp::Controller::default()) .with(body) .with(stats) - .with(comp::Energy::new(100)) + .with(comp::Energy::new(500)) .with(comp::Gravity(1.0)) .with(comp::CharacterState::default()) }