Problem with turn/bank a object

Hello!

Im trying to make a object turn and bank while going forward/backward.

I have tried different ways and always ending up with a effect like a car on ice instead of steady make a turn and banking…some sort of a aircraft behavior
Any help about this is greatly appreciated.

And also problem with my input code, it just make a object turn right and not left, the input “Turn” have Negative button A, and Positive button D, do i use the wrong code? i guess so since Right is positive D

        if (Input.GetAxis("Turn") > 0)
        {
           
        }

Apply a forward force, a lateral force and a rotational force all at the same time and it should feel like a power assisted turn.

As for your input, you’re only turning right because you’re checking if the value is > 0. Left would be < 0.

Assuming your input axis is setup correctly, something like this should work:

rigidbody.AddRelativeForce(0f, 0f, 10.0f); // forward
rigidbody.AddRelativeForce(0f, -Input.GetAxis("Turn") * 10.0f, 0f); // lateral
rigidbody.AddRelativeTorque(0f, Input.GetAxis("Turn") * 10.0f, 0f); // rotational

How about parenting your model to an empty object. Move the empty object instead of the model, then add a script to bank and tilt the child model according to its movements.

Yes, i thought the input “Turn” would work with + and - depending on what key you pressed if the value is not 0. if you understand what i mean?

I tried your code there, it do rotate the ship right and left, but when i release the button, it keeps rotating until it stops by it self, and when it goes forward it sliding around like on ice while rotating.

        if (Input.GetAxis("Turn") != 0)
        {
            Ship.AddRelativeForce(0f, 0f, 10.0f); // forward
            Ship.AddRelativeForce(0f, -Input.GetAxis("Turn") * Turnspeed, 0f); // lateral
            Ship.AddRelativeTorque(0f, Input.GetAxis("Turn") * Turnspeed, 0f); // rotational
        }

Imagine a circle of 8, when the ship goes forward and comes to the curves, the ship should bank/roll inwards in given max degrees, in this case when you press A or D, and when the curve ends, also the banking/roll ends, in this case when you release the button and start to go straight forward.

If you want the ship to stop automatically, increase the linear and angular drag on the rigidbody or start reading up on PID controllers.