Hi,
I’m trying to rotate my camera based off of a variable “gravityState” and I have no idea what to put in the brackets of the if statement to recognise this variable going up or down by 1.
The following is my code so far for when the variable “gravityState” goes up by 1.
if ( //required statement //)
{
Vector3 to = new Vector3(0, 0, 90);
if (Vector3.Distance(transform.eulerAngles, to) > 0.01f)
{
transform.eulerAngles = Vector3.Lerp(transform.rotation.eulerAngles, to, Time.deltaTime*5);
}
else
{
transform.eulerAngles = to;
}
}
Also, in my testing for when the variable goes down I found that when changing “90” in line 3 of the code to “-90” the camera would spin forever, does anyone know why?
Any help is appreciated.