Godot version: 4.3
here’s all the code just to get it out of the way:
using Godot;
using System;
using static Godot.WebSocketPeer;
public partial class Plane : RigidBody3D
{
private const JoyAxis throttleAxis = JoyAxis.TriggerRight;
private const JoyAxis pitchAxis = JoyAxis.LeftY;
private const JoyAxis rollAxis = JoyAxis.LeftX;
private const JoyAxis yawAxis = JoyAxis.RightX;
private float throttleValue;
private float pitchValue;
private float rollValue;
private float yawValue;
private const int dryThrust = 64900;
private const int afterburnerThrust = 106000;
private Vector3 thrustForce;
public override void _Ready()
{
Mass = 9207f;
LinearDamp = 0f;
AngularDamp = 0f;
CanSleep = false;
}
public override void _PhysicsProcess(double delta)
{
Vector3 forwardVector = -Transform.Basis.Z;
getAxisValues();
applyThrust(forwardVector);
GD.Print($"throttle: {throttleValue} pitch: {pitchValue} roll: {rollValue} yaw: {yawValue} thrust: {thrustForce.Length()} speed: {LinearVelocity.Length() * 3600 / 1000}/{LinearVelocity.Length()}");
}
private void getAxisValues()
{
throttleValue = -Input.GetJoyAxis(0, throttleAxis);
throttleValue = (throttleValue + 1) / 2;
pitchValue = Input.GetJoyAxis(0, pitchAxis);
rollValue = Input.GetJoyAxis(0, rollAxis);
yawValue = Input.GetJoyAxis(0, yawAxis);
}
private void applyThrust(Vector3 forward)
{
if (throttleValue > 0.9)
{
thrustForce = forward * afterburnerThrust;
} else
{
thrustForce = forward * dryThrust * (throttleValue * (1f / 0.9f));
}
ApplyForce(thrustForce, new Vector3(0, -0.182f, 4.04f));
}
}
The code is on a Rigidbody3D with a meshInstance3D with an imported 3D model, a collision shape which is a simplified convex of the mesh instance and a camera3D
The Rigidbody3D is placed in a scene with just itself, a directionalLight3D and a worldEnvironment. Even when I don’t apply any forces on it, so just letting it free fall forever it will eventually slow down and even stop accelerating.
From what I’ve heard the only force that’s applied by default is Gravity and damping (which I’ve set to zero), so I can’t figure out for the life of me what’s causing it to slow down.
When I apply a force this also happens, the mass of the Rigidbody is 9000kg and the force is 100’000 newtons, so it should accelerate at about 10m/s, but it still tops out at about 500km/h or 100m/s.
I have no idea what’s causing this to happen, if I need to give any other information to help just tell me, I would love any help, thanks!