From 811ddecdb23bf83d7d089ce494cc27cafcf773de Mon Sep 17 00:00:00 2001 From: TerraMaster85 Date: Fri, 11 Jul 2025 14:24:37 -0400 Subject: [PATCH] shut off opposing thrusters --- crates/unified/src/server/player.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/unified/src/server/player.rs b/crates/unified/src/server/player.rs index 262583f5d237d4b9ea769039cae12fc7d3a1c52a..aecb2846614d72c4c068926fdbcdf7d49bc3061a 100644 --- a/crates/unified/src/server/player.rs +++ b/crates/unified/src/server/player.rs @@ -118,7 +118,14 @@ fn player_thrust( let forward = (transform.rotation * Vec3::Y).xy(); let mut external_force = ExternalForce::default(); - let mut thrusters = [0.0; 4]; // counterclockwise wrt +y axis + + // indices are quadrants: + // 1 | 0 + // --+-- + // 2 | 3 + // + let mut thrusters = [0.0; 4]; + if thrust.up { thrusters[1] = 1.0; thrusters[2] = 1.0; @@ -135,6 +142,11 @@ fn player_thrust( thrusters[1] = 1.0; thrusters[3] = 1.0; } + + // prevent fuel wasting when turning while moving forward/reverse + if thrusters[2] == thrusters[3] && thrusters[3] != 0.0 { (thrusters[2], thrusters[3]) = (0.0, 0.0); } + if thrusters[0] == thrusters[1] && thrusters[1] != 0.0 { (thrusters[0], thrusters[1]) = (0.0, 0.0); } + let half_size = Vec2::new( world_config.part.default_width / 2.0, world_config.part.default_height / 2.0,