Object over rotates when rotating. how do I stop the rotation of an object going when direction when I press a key to make it go the other.
I don’t see any torque being applied in this code at all. You’re using transform.Rotate. That will just directly rotate the object, with no change to the angular velocity. So if you picked up an angular velocity by hitting a wall or something, it will keep spinning that way, even if you just set the rotation.
If you want to change the rotational velocity of the rigidbody you need to use Rigidbody.AddTorque.
Another big issue with your code is you should only apply changes to the rigidbody inside FixedUpdate, not Update.
So 2 things:
- use rb.AddTorque to do rotation
- Move AddForce and AddTorque calls to FixedUpdate