- Home /
How do I limit my car's z rotation when a key is pressed?
So I'm making a car game and everything seems to work but I cannot resolve the problem where the car drives on two wheels and rolls over when I turn while accelerating. I know that would happen in real life but it tips over at less than 10mph so I can't even make a 90 degree turn. I have decided to limit the amount the car can roll (on the z axis) as doing two wheels can suit my game but the limit only occurs when left or right are pressed, as in the car cannot rotate more than 20 degrees to the right while the right key is pressed.
Can somebody please make me a basic JavaScript or C# script that will do this?
By the way I am using wheelcolliders, box colliders and a rigidbody.
Ins$$anonymous$$d of this specific solution, maybe you want to search UA for other answers to the problem of a car tipping over. I believe lowering the center of gravity makes a big difference for example.