come to a full stop when braking while slow
This commit is contained in:
parent
0717495d57
commit
b3885aa4b6
|
@ -126,8 +126,20 @@ fn run_camera_controller(
|
||||||
|
|
||||||
if axis_input.length_squared() > 0.003 {
|
if axis_input.length_squared() > 0.003 {
|
||||||
let acceleration_global = transform.rotation * (axis_input * factor);
|
let acceleration_global = transform.rotation * (axis_input * factor);
|
||||||
actor.v += actor::ENGINE_SPEED_FACTOR * dt * acceleration_global;
|
let mut acceleration_total = actor::ENGINE_SPEED_FACTOR * dt * acceleration_global;
|
||||||
|
let threshold = 1e-5;
|
||||||
|
if key_input.pressed(settings.key_stop) {
|
||||||
|
for i in 0..3 {
|
||||||
|
if actor.v[i].abs() < threshold {
|
||||||
|
actor.v[i] = 0.0;
|
||||||
|
}
|
||||||
|
else if (actor.v[i] < 0.0 && actor.v[i] + acceleration_total[i] > 0.0) || (actor.v[i] > 0.0 && actor.v[i] + acceleration_total[i] < 0.0) {
|
||||||
|
actor.v[i] = 0.0;
|
||||||
|
acceleration_total[i] = 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
actor.v += acceleration_total;
|
||||||
engine.current_warmup = (engine.current_warmup + dt / engine.warmup_seconds).clamp(0.0, 1.0);
|
engine.current_warmup = (engine.current_warmup + dt / engine.warmup_seconds).clamp(0.0, 1.0);
|
||||||
play_thruster_sound = !settings.mute_sfx;
|
play_thruster_sound = !settings.mute_sfx;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue