mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Minor control over velocity when in the air
This commit is contained in:
parent
98f660e486
commit
3af4793762
@ -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,21 +247,21 @@ 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)
|
||||
{
|
||||
// Should ability to backpedal be separate from ability to strafe?
|
||||
update.vel.0 += Vec2::broadcast(data.dt.0)
|
||||
* accel
|
||||
* if data.body.can_strafe() {
|
||||
data.inputs.move_dir
|
||||
} else {
|
||||
let fw = Vec2::from(update.ori);
|
||||
fw * data.inputs.move_dir.dot(fw).max(0.0)
|
||||
};
|
||||
}
|
||||
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
|
||||
* if data.body.can_strafe() {
|
||||
data.inputs.move_dir
|
||||
} else {
|
||||
let fw = Vec2::from(update.ori);
|
||||
fw * data.inputs.move_dir.dot(fw).max(0.0)
|
||||
};
|
||||
}
|
||||
|
||||
/// Handles forced movement
|
||||
|
Loading…
Reference in New Issue
Block a user