Make test thruster work
This commit is contained in:
parent
1b76cb3d82
commit
fb666f4d81
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user