addforce elevator behaviour

Hello,

I think I am missing something, but I didn’t see what. So with your help…
I ve imported a spaceship fbx by drag & drop into assets. I put the ship in my scene, add a rigidbody, and a script.

I desactivate gravity, put damping to 1, and fix a mass to 500.

in my script, I apply some torque on keypressed. And it is ok.
Now I wish to addForce (acceleration) to move forward.

void FixedUpdate()
    {
        Rigidbody rb = GetComponent<Rigidbody>();
rb.AddForce(transform.forward * 100,ForceMode.Acceleration);
}

But my ship is not going forward, but more than an elevator, on y axis up and down…

Do you have an advice?

The ship model may have been exported from a program that uses Z up axis without being corrected which means transform.up will actually be forward. You may want to check the default rotation value of the ship, if it isn’t 0,0,0 then the shortcuts like forward, up, right etc may not work as expected.

Also you shouldn’t run Rigidbody rb = GetComponent<Rigidbody>(); every single frame like that. Cache it on start instead.

private Rigidbody rb.

void Start()
{
   rb = GetComponent<Rigidbody>();
}