Minor control over velocity when in the air

This commit is contained in:
Joshua Barretto 2021-04-25 22:37:25 +01:00
parent 98f660e486
commit 3af4793762

View File

@ -106,6 +106,8 @@ impl Body {
}
}
pub fn air_accel(&self) -> f32 { self.base_accel() * 0.025 }
/// Attempt to determine the maximum speed of the character
/// when moving on the ground
pub fn max_speed_approx(&self) -> f32 {
@ -245,11 +247,12 @@ pub fn handle_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) {
fn basic_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) {
handle_orientation(data, update, efficiency);
if let Some(accel) = data
.physics
.on_ground
.then_some(data.body.base_accel() * efficiency)
{
let accel = if data.physics.on_ground {
data.body.base_accel()
} else {
data.body.air_accel()
} * efficiency;
// Should ability to backpedal be separate from ability to strafe?
update.vel.0 += Vec2::broadcast(data.dt.0)
* accel
@ -259,7 +262,6 @@ fn basic_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) {
let fw = Vec2::from(update.ori);
fw * data.inputs.move_dir.dot(fw).max(0.0)
};
}
}
/// Handles forced movement