Set Y rotation on already spinning object
OK, I feel like such a noob with constant rotation questions, but I have yet another one (just 2 years in now!).
I have a wheel spinning happily enough on it's x-axis. However, I would like to give it a specific y rotation based on the steering wheel rotation (ie between -45 and 45).
But I'm tinkering away and can't find the "right" answer. If I use euler angles, the wheel does this weird backwards and forwards spin.
leftWheel.eulerAngles = new Vector3 (leftWheel.eulerAngles.x, rotationAmount, leftWheel.eulerAngles.z);
Pretty sure this because euler angles converted to quaternions can give the y and z values a 180, and then reduce the x amount. All rather bonkers, but I know that quaternions are a place only for the super brainy!
So does anybody have a clue on how I can get the y value set to a specific rotation without screwing up the "roll" of the wheel?
I've dealt with this weird issue a lot of times, too. The only solution I've found is to set the euler angles to a temporary Vector3 variable, change its y axis, then re-assign the rotation back to that.
You can also try transform.rotation = Quaternion.Euler(...)
Answer by richard_hawkes · Aug 22, 2016 at 05:21 AM
Thanks Firedan, but the thing is that I don't know what one of the rotations will be (because the wheel is spinning). The y-axis is the one I want to change, but its Euler angles flip from 0 to 180 during rotation of the x-axis for some reason.
Your answer
Follow this Question
Related Questions
Auto level an object 0 Answers
How can I set rotation properly? 0 Answers
How to Rotate on Y Axis by 90 degrees left or right? 1 Answer
Portals: Transformation of ported Objects 1 Answer
Slerp Rotating 1 Degree and Limiting All Other Rotation 1 Answer