I just started learning and developing game development using C# in Unity. My first project is creating an object car and making it move.
A problem I have is that when the car hits an obstacle sometimes it flips and can’t turn upright again. I want it to be able to turn to its original rotation after some time lying down flipped so the user can continue to drive the car.
I tried this but did not work:
public Quaternion og_rotation;
// Start is called before the first frame update
void Start()
{
og_rotation = transform.rotation;
}
void Update(){
if (transform.rotation.z > 100) {
transform.rotation = og_rotation;
}
}