0
\$\begingroup\$

I have a standart Unity car with Unity Car physics. What would be the best approach to protect my car from a rollover?

I dont want to mess up and try and error 10 different approaches, so maybe here is an expert who really knows how to do it right?

I couldnt find anything decent on the internet.

\$\endgroup\$
0
\$\begingroup\$

Ideally use AddRelativeTorque. In its simplest form, flip the car on its Z axis when the car is upside down.

RigidBody RB = ...;
float flipStrength = 1f;

if (Mathf.Abs(transform.localRotation.eulerAngles.z) > 90f) {
    RB.AddRelativeTorque(0f, 0f, flipStrength, ForceMode.Acceleration);
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.