Smarter vel zeroing.
This commit is contained in:
parent
26f2331743
commit
3ebe2f57ce
1 changed files with 6 additions and 10 deletions
|
@ -89,12 +89,8 @@ fn update_player_vel(
|
|||
};
|
||||
|
||||
// thrust or brake
|
||||
let accel = xform.forward() * input.throttle * dt * settings.accel;
|
||||
if pstate.velocity.is_finite() {
|
||||
vel += accel;
|
||||
} else {
|
||||
vel = accel;
|
||||
}
|
||||
vel += xform.forward() * input.throttle * dt * settings.accel;
|
||||
|
||||
|
||||
// brake
|
||||
if input.brake {
|
||||
|
@ -108,11 +104,11 @@ fn update_player_vel(
|
|||
|
||||
// drag
|
||||
let v2 = vel.length_squared().min(100_000.0);
|
||||
if v2 < 0.05 {
|
||||
vel = Vec3::ZERO;
|
||||
} else {
|
||||
let drag = vel * settings.drag * v2 * dt;
|
||||
vel -= drag;
|
||||
|
||||
if !vel.is_finite() {
|
||||
vel = Vec3::ZERO;
|
||||
}
|
||||
|
||||
pstate.velocity = vel;
|
||||
|
|
Loading…
Reference in a new issue