Why does your car flip in every turn?

Its center of mass sits too high.

Why does your car flip in every turn?

The problem

Mass in the middle.

void Awake(){    rb = GetComponent<Rigidbody>();    // centerOfMass: worked out from the colliders}

Unity puts the center of mass in the middle of the colliders. A tall body box puts it high, so turns tip it over.

The fix

Lower the center of mass.

Set rb.centerOfMass to a low local point, near the axles.

rb.centerOfMass→low point→stays upright

The fix in code

Low and stable.

void Awake(){    rb = GetComponent<Rigidbody>();    rb.centerOfMass = new Vector3( 0f, -0.4f, 0f );}

The point is local to the car. Lower means harder to roll.

Watch out

Things to know.

Once you set it, Unity stops working it out for you.

Space
local to the body
Changed colliders
set it again
Undo it
ResetCenterOfMass()

The rule

Tippy bodies get a low center.

Cars, carts
lower it
Space
local
Reset
ResetCenterOfMass