I want the game to be over as soon as car hits the obstacle, but somehow when I toggled on my isTrigger button, the car is jumping all around the places, I tried changing it to mesh collider, I tried using different colliders for different children, I kept my box collider far from the ground to be touched, I haven’t written a code in onCollisionEnter function yet. It’s not a problem with suspension or rigidbody, because the car is working just fine when the trigger is off. Click the below video link to see.
If you want to have your car not move at the Y axis and if you have a rigidbody component on your car then I think you can freeze the position on the Y inside the editor. Or if you want to have it move on the Y axis and then when it hits an obstacle you can freeze the position through code like this.
void OnTriggerEnter(Collider collider)
{
if (collider.tag == "Obstacle")
{
//If you have an reference to the rigidbody then you can do this
rigidbody.constraints = RigidbodyConstraints.FreezePositionY;
}
//Hope this would help
}