Problem with using Rotate and localEulerAngles...

Why does this not work?

object.localEulerAngles = new Vector3(0,changingValue, 0);
object.Rotate(60*Time.deltaTime, 0, 0);
//the result of this is "object" randomly alternates from turning and stoping...

Does anyone know why this happens and how to fix it? “Object” was rotating fine without this line of code(that I need): object.localEulerAngles = new Vector3(0,changingValue, 0);

I feel like I tried everything possible but I still can’t fix this issue.

Thanks in advanced :slight_smile:

What’s happening is that setting localEulerAngles is zeroing out the x rotation every frame. Try making a copy of the euler angles, changing only the y value, then setting it back:

Vector3 angles = object.localEulerAngles;
angles.y = changingValue;
object.localEulerAngles = angles;
object.Rotate(60*Time.deltaTime, 0, 0);

Even better would be to combine changing x and y rotation into one operation:

Vector3 angles = object.localEulerAngles;
angles.x += 60*Time.deltaTime;
angles.y = changingValue;
object.localEulerAngles = angles;