public override void _IntegrateForces(Physics2DDirectBodyState state) { AppliedForce = state.TotalGravity; AppliedTorque = 0f; if (ThrusterControls.IsUFODriveEnabled) { var clampedVelocity = ThrusterControls.UFODriveVelocity.Normalized() * Mathf.Min(ThrusterControls.UFODriveVelocity.Length(), ufoDriveMaxSpeed); state.LinearVelocity = clampedVelocity; //state.LinearVelocity = ThrusterControls.UFODriveVelocity; state.AngularVelocity = ThrusterControls.UFODriveAngularVelocity; } else { AddForce(mainThruster.GlobalPosition - GlobalPosition, mainThruster.GetResultantThrustVector()); AddForce(portRetroThruster.GlobalPosition - GlobalPosition, portRetroThruster.GetResultantThrustVector()); AddForce(starboardRetroThruster.GlobalPosition - GlobalPosition, starboardRetroThruster.GetResultantThrustVector()); AddForce(portForeThruster.GlobalPosition - GlobalPosition, portForeThruster.GetResultantThrustVector()); AddForce(portAftThruster.GlobalPosition - GlobalPosition, portAftThruster.GetResultantThrustVector()); AddForce(starboardForeThruster.GlobalPosition - GlobalPosition, starboardForeThruster.GetResultantThrustVector()); AddForce(starboardAftThruster.GlobalPosition - GlobalPosition, starboardAftThruster.GetResultantThrustVector()); } //Enable/Disable the UFO Drive visuals depending on chosen PropulsionMode //ufoDriveParticles.SetEmitting(PropulsionMode == ShipPropulsionMode.ManualUFODrive); ufoDriveParticles.SetEmitting(ThrusterControls.IsUFODriveEnabled); if (Input.IsActionJustPressed("MovementStop")) { state.LinearVelocity = Vector2.Zero; state.AngularVelocity = 0f; } int contactCount = state.GetContactCount(); if (contactCount > 0) { //GD.Print("Contact count: " + contactCount); for (int i = 0; i < contactCount; i++) { var vector = state.GetContactColliderVelocityAtPosition(i); //GD.Print("Vector: " + vector); } } }