Stabilize Car while Jumping / Set trajectory

Hi All!

I need to stabalize my car when I jump of a ramp, so that it doesn’t flip over all the time.

How do I do this (in Javascript). What are the functions that check the rotation of an object, and how would you apply it? Just checking if the wheels have left the ground, and then just turn the car horizontal immediately will probably look very, very bad, so there has to be somewhat of a natural trajectory to the jump: Slowly turn the car back to a horizontal position…

Would I have to calculate how long the jump is going to take. and then use percentages to adjust the rotation? If so, How would I do this? If not, are there other, smarter, better ways to acclompish this?

Thanks in advance!

You could try changing the center of gravity in the vehicle which will affect how it rotates in the air.

Or you can still check if the wheels are grounded but instead of setting a rotation you could dampen the rotation until the wheels hit again. You’ll need to use [rigidbody.AddTorque](file://localhost/Applications/Unity/Documentation/ScriptReference/Rigidbody.AddTorque.html).

Here’s a related question that has an answer with an example adding force against the unwanted rotation.