Here is a quick SUGGESTION: In start store the rotation of the car in a Vector3 variable. After the car is flipped sideways, set the rotation again to the stored value.
public class CarController : MonoBehavior
{
// adjust the angles as per your needs
public float maxLeftAngle = 315f;
public float maxRightAngle = 45f;
void Update()
{
if ((transform.rotation.eulerAngles.z < maxLeftAngle) || (transform.rotation.eulerAngles.z > maxRightAngle))
{
Debug.Log("The car is turned sideways");
// reset the rotation
}
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…