From fb666f4d81660c01cd64fb40dd62dea7ec661196 Mon Sep 17 00:00:00 2001 From: Yuki Kitagawa Date: Wed, 23 Oct 2024 23:16:02 +0800 Subject: [PATCH] Make test thruster work --- src/testing/TestThruster.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/testing/TestThruster.cs b/src/testing/TestThruster.cs index 4c0b5cb..e128e6e 100644 --- a/src/testing/TestThruster.cs +++ b/src/testing/TestThruster.cs @@ -25,16 +25,18 @@ public partial class TestThruster : RigidBody3D public override void _Process(double delta) { + float throttleStep = 0.2f * (float)delta; if (Input.IsKeyPressed(Key.Shift)) { - Throttle += 0.1f * (float)delta; + Throttle += throttleStep; } else if (Input.IsKeyPressed(Key.Ctrl)) { - Throttle -= 0.1f * (float)delta; + Throttle -= throttleStep; } - torque = Vector3.Zero; + var torque = Vector3.Zero; + float torqueStep = 0.1f; if (Input.IsKeyPressed(Key.W)) { torque += new Vector3(-1.0f, 0.0f, 0.0f); // Forward (X-) @@ -59,7 +61,8 @@ public partial class TestThruster : RigidBody3D { torque += new Vector3(0.0f, -1.0f, 0.0f); // Down (Y-) } - torque *= 0.01f; + torque *= torqueStep; + this.torque = torque; if (Input.IsKeyPressed(Key.T) && !stabilizeDebounce) { @@ -91,13 +94,13 @@ public partial class TestThruster : RigidBody3D public override void _PhysicsProcess(double delta) { var thrust = Throttle * 100.0f; - var thrustVec = this.Transform * new Vector3(0.0f, thrust, 0f); + var thrustVec = this.Transform.Basis * new Vector3(0.0f, thrust, 0f); this.ApplyCentralForce(thrustVec); Vector3 torque; if (!this.torque.IsZeroApprox()) { - torque = this.torque; + torque = this.Transform.Basis * this.torque; } else if (stabilize) {