diff --git a/src/actor.rs b/src/actor.rs index ed11b42..759db97 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -57,6 +57,7 @@ impl Plugin for ActorPlugin { .after(sync::position_to_transform), handle_gforce .run_if(game_running) + .run_if(alive) .after(PhysicsSet::Sync) .after(sync::position_to_transform) .after(handle_wants_acceleration), @@ -870,6 +871,8 @@ fn handle_wants_acceleration( engine.current_warmup = (engine.current_warmup + dt / engine.warmup_seconds).clamp(0.0, 1.0); + delta_v = delta_v.clamp(DVec3::splat(-1.0), DVec3::splat(1.0)); + // Adjust acceleration to what the engine can actually provide let factor_forward = if accel.direction.z > 0.0 { engine.thrust_forward @@ -883,10 +886,8 @@ fn handle_wants_acceleration( * ENGINE_SPEED_FACTOR as f64 * engine.current_boost_factor; - let final_accel = (trans.rotation - * (delta_v.clamp_length_max(1.0) * engine_factor).as_vec3() - * dt) - .as_dvec3(); + let final_accel = + (trans.rotation * (delta_v * engine_factor).as_vec3() * dt).as_dvec3(); // Apply acceleration to velocity if allow_fullstop {