I have a car with four wheel colliders and 4 wheel meshes, everything is working great but I need a way to detect that the vehicle has tipped over. I have purposefully set a high center of mass and the vehicle tips fairly easily, I just need a way to detect that it has in fact tipped over. Any pointers are appreciated.
You could check to see whether the y-component of transform.up is negative, or otherwise below a certain value:
//...
if (transform.up.y <= 0)
{
Debug.Log("Vehicle has toppled.");
}
//...
You can run this in OnCollisionEnter() to check for other things, like whether the vehicle is touching the ground or not. That would be useful if you only want to know when it’s rolled over on the ground, rather than in the air.