Question by
AsifNaeem · Dec 08, 2018 at 06:12 PM ·
rotationeulerangles
Camera Rotation and Re-rotation
I am trying to rotate my camera around a object. When it reaches at euler angle > 50 it changes its rotation back. It decrements the values of Euler Angle from 50. Then goes o, 360, 359, 358, 357... So on.
I want to reverse its rotation again at angle reaches 300. But I am unable to do it after spending couple of hours. I dont understand ho to create a check for reverse when it reaches at 300
Here is my code
bool changeRot;
void Update () {
if (!changeRot)
{
transform.Rotate(0f, 5 * Time.deltaTime, 0f);
if(transform.localEulerAngles.y > 50)
{
changeRot = true;
}
}
else if (changeRot)
{
transform.Rotate(0f, -5 * Time.deltaTime, 0f); // Reverse the rotation
}
}
}
Comment