Smoother movement, Space for climbing

This commit is contained in:
Joshua Barretto 2019-10-14 11:22:48 +01:00
parent 4bbc340f52
commit 707b79f2c8
5 changed files with 12 additions and 6 deletions

View File

@ -13,7 +13,7 @@ use vek::*;
pub const ROLL_DURATION: Duration = Duration::from_millis(600); pub const ROLL_DURATION: Duration = Duration::from_millis(600);
const HUMANOID_ACCEL: f32 = 70.0; const HUMANOID_ACCEL: f32 = 50.0;
const HUMANOID_SPEED: f32 = 120.0; const HUMANOID_SPEED: f32 = 120.0;
const HUMANOID_AIR_ACCEL: f32 = 10.0; const HUMANOID_AIR_ACCEL: f32 = 10.0;
const HUMANOID_AIR_SPEED: f32 = 100.0; const HUMANOID_AIR_SPEED: f32 = 100.0;
@ -163,7 +163,7 @@ impl<'a> System<'a> for Sys {
ori.0 = vek::ops::Slerp::slerp( ori.0 = vek::ops::Slerp::slerp(
ori.0, ori.0,
ori_dir.into(), ori_dir.into(),
if physics.on_ground { 12.0 } else { 2.0 } * dt.0, if physics.on_ground { 9.0 } else { 2.0 } * dt.0,
); );
} }

View File

@ -18,7 +18,7 @@ const BOUYANCY: f32 = 0.0;
// amount an object will slow down within 1/60th of a second. Eg. if the frction // 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 // 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. // be 0.99. after 1 second the speed will be 0.54, which is 0.99 ^ 60.
const FRIC_GROUND: f32 = 0.125; const FRIC_GROUND: f32 = 0.08;
const FRIC_AIR: f32 = 0.0125; const FRIC_AIR: f32 = 0.0125;
const FRIC_FLUID: f32 = 0.2; const FRIC_FLUID: f32 = 0.2;

View File

@ -161,6 +161,7 @@ impl Scene {
self.figure_state.update( self.figure_state.update(
renderer, renderer,
Vec3::zero(), Vec3::zero(),
Vec3::zero(),
Vec3::new(self.char_ori.sin(), -self.char_ori.cos(), 0.0), Vec3::new(self.char_ori.sin(), -self.char_ori.cos(), 0.0),
1.0, 1.0,
Rgba::broadcast(1.0), Rgba::broadcast(1.0),

View File

@ -257,6 +257,7 @@ impl FigureMgr {
state.update( state.update(
renderer, renderer,
pos.0, pos.0,
vel.0,
ori.0, ori.0,
scale, scale,
col, col,
@ -311,6 +312,7 @@ impl FigureMgr {
state.update( state.update(
renderer, renderer,
pos.0, pos.0,
vel.0,
ori.0, ori.0,
scale, scale,
col, col,
@ -367,6 +369,7 @@ impl FigureMgr {
state.update( state.update(
renderer, renderer,
pos.0, pos.0,
vel.0,
ori.0, ori.0,
scale, scale,
col, col,
@ -385,6 +388,7 @@ impl FigureMgr {
state.update( state.update(
renderer, renderer,
pos.0, pos.0,
vel.0,
ori.0, ori.0,
scale, scale,
col, col,
@ -524,6 +528,7 @@ impl<S: Skeleton> FigureState<S> {
&mut self, &mut self,
renderer: &mut Renderer, renderer: &mut Renderer,
pos: Vec3<f32>, pos: Vec3<f32>,
vel: Vec3<f32>,
ori: Vec3<f32>, ori: Vec3<f32>,
scale: f32, scale: f32,
col: Rgba<f32>, col: Rgba<f32>,
@ -535,8 +540,8 @@ impl<S: Skeleton> FigureState<S> {
// Update interpolation values // Update interpolation values
if self.pos.distance_squared(pos) < 64.0 * 64.0 { if self.pos.distance_squared(pos) < 64.0 * 64.0 {
self.pos = Lerp::lerp(self.pos, pos, 15.0 * dt); self.pos = Lerp::lerp(self.pos, pos + vel * 0.03, 10.0 * dt);
self.ori = Slerp::slerp(self.ori, ori, 7.5 * dt); self.ori = Slerp::slerp(self.ori, ori, 5.0 * dt);
} else { } else {
self.pos = pos; self.pos = pos;
self.ori = ori; self.ori = ori;

View File

@ -65,7 +65,7 @@ impl Default for ControlSettings {
jump: KeyMouse::Key(VirtualKeyCode::Space), jump: KeyMouse::Key(VirtualKeyCode::Space),
sit: KeyMouse::Key(VirtualKeyCode::K), sit: KeyMouse::Key(VirtualKeyCode::K),
glide: KeyMouse::Key(VirtualKeyCode::LShift), glide: KeyMouse::Key(VirtualKeyCode::LShift),
climb: KeyMouse::Key(VirtualKeyCode::LShift), climb: KeyMouse::Key(VirtualKeyCode::Space),
climb_down: KeyMouse::Key(VirtualKeyCode::LControl), climb_down: KeyMouse::Key(VirtualKeyCode::LControl),
wall_leap: KeyMouse::Mouse(MouseButton::Middle), wall_leap: KeyMouse::Mouse(MouseButton::Middle),
mount: KeyMouse::Key(VirtualKeyCode::F), mount: KeyMouse::Key(VirtualKeyCode::F),