diff --git a/src/actor.rs b/src/actor.rs index 8cf498b..2adf28c 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -834,7 +834,8 @@ fn handle_wants_acceleration( if accel.brake { if let Some(target_v) = closest_map.get(&entity) { - delta_v = *target_v - v.0; + let stop_direction = (*target_v - v.0).as_vec3(); + delta_v = (trans.rotation.inverse() * stop_direction).as_dvec3(); if delta_v.length_squared() > 0.003 { engine.currently_matching_velocity = true; thruster_on = true; @@ -844,7 +845,7 @@ fn handle_wants_acceleration( if accel.direction != DVec3::ZERO { // Player is pressing AWSD keys - delta_v += (trans.rotation * accel.direction.as_vec3()).as_dvec3(); + delta_v += accel.direction; } else if accel.brake { // Player is only pressing space allow_fullstop = true; @@ -869,7 +870,9 @@ fn handle_wants_acceleration( * ENGINE_SPEED_FACTOR as f64 * engine.current_boost_factor; - let final_accel = delta_v.normalize() * engine_factor * dt as f64; + let final_accel = + (trans.rotation * (delta_v.normalize() * engine_factor).as_vec3() * dt) + .as_dvec3(); // Apply acceleration to velocity if allow_fullstop {