I’m using a simple car model that has 4 WheelColliders attached to it and has a single Box Collider for itself.
I know that the center of mass should be lowered to make the car less likely to flip. However, no matter what values I use, it seems that the physics are generated almost randomly.
I tried doing something like
rigidbody.centerOfMass = new Vector3(0,-1,0);
and played around with many values. I also tried using the center of mass that the car already has and lowering the Y value a bit.
However, the physics seems to decide randomly where that actually is. Sometimes everything is perfect and the car is almost impossible to flip over, sometimes it actually wants to flip over and turns around once I steer or drive over a slightly higher object. Sometimes it wants to stay on the side.
I’ve read hundreds of topics about all the things you can do to prevent cars from flipping over by now, but nothing seems to work for me. I added stabilizer bars, I’ve tested dozens of values for the center of mass, I played around with the rigidbody and WheelColliders values, all with no change at all.
Any help would be appreciated.
E: Another possible interesting point:
I’m getting into the car game after a level switch and the user activates it later (Which means: The whole car game is in a GameObject that is inactive first). It seems that the problem doesn’t occur when I am doing tests with a configuration in which the car game starts immediately. Any ideas what could change how the physics act in that context?
Further testing proved that this does happen when I deactivate the GameObject. So I was able to fix it by letting this sub-game active the whole time and just deactivating all sounds and control. Since that isn’t the best solution performance-wise I’d still like to know if there’s a way to play around with the activation and still have stable physics.