- Home /
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 :)
Answer by zach-r-d · Jul 27, 2015 at 08:22 AM
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;
Your answer

Follow this Question
Related Questions
Problems rotating back to zero 2 Answers
localEulerAngles don't seem to work in an equasion 3 Answers
Camera rotation around player while following. 6 Answers
localEulerAngles.x rotates as in world space 1 Answer
Wheels Rotate or Turn, but not both 1 Answer