From cb50998c3b15746f9231b97c7e24e7eead862618 Mon Sep 17 00:00:00 2001 From: ghostly_zsh Date: Sun, 23 Nov 2025 08:18:34 -0600 Subject: [PATCH] fix: target_unit_vector is now rotated --- crates/unified/src/client/ship/thrusters.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/crates/unified/src/client/ship/thrusters.rs b/crates/unified/src/client/ship/thrusters.rs index f16c5dce524d7661b0a6aee52f51e538e412325f..425a389dc17b5003da28dfcfc99e8fa7d8b801d4 100644 --- a/crates/unified/src/client/ship/thrusters.rs +++ b/crates/unified/src/client/ship/thrusters.rs @@ -76,6 +76,12 @@ fn solve_thrust( solution.thrusters_on.clear(); solution.converged = false; + let Ok((our_parts, hearty_transform, hearty)) = me.single() else { + error!("could not solve for thrust: hearty does not exist?"); + error!("failed to solve for thrust after {}ms", start.elapsed().as_millis()); + return; + }; + // determine our target vector: // unit vector in the intended direction of movement @@ -86,16 +92,16 @@ fn solve_thrust( let mut target_unit_vector = Vec3::ZERO; if input.pressed(&ClientAction::ThrustForward) { - target_unit_vector += Vec3::new(0.0, -1.0, 0.0); + target_unit_vector += hearty_transform.rotation() * Vec3::new(0.0, -1.0, 0.0); } if input.pressed(&ClientAction::ThrustBackward) { - target_unit_vector += Vec3::new(0.0, 1.0, 0.0); + target_unit_vector += hearty_transform.rotation() * Vec3::new(0.0, 1.0, 0.0); } if input.pressed(&ClientAction::ThrustRight) { - target_unit_vector += Vec3::new(-1.0, 0.0, 0.0); + target_unit_vector += hearty_transform.rotation() * Vec3::new(-1.0, 0.0, 0.0); } if input.pressed(&ClientAction::ThrustLeft) { - target_unit_vector += Vec3::new(1.0, 0.0, 0.0); + target_unit_vector += hearty_transform.rotation() * Vec3::new(1.0, 0.0, 0.0); } if input.pressed(&ClientAction::TorqueCw) { target_unit_vector += Vec3::new(0.0, 0.0, -1.0); @@ -112,11 +118,6 @@ fn solve_thrust( return; } - let Ok((our_parts, hearty_transform, hearty)) = me.single() else { - error!("could not solve for thrust: hearty does not exist?"); - error!("failed to solve for thrust after {}ms", start.elapsed().as_millis()); - return; - }; let mut all_parts = vec![hearty]; if let Some(parts) = our_parts { all_parts.extend(parts.iter()); @@ -215,4 +216,4 @@ fn solve_thrust( *solution = new_soln; events.write(ThrustEvent(solution.clone())); return; -} \ No newline at end of file +}