So the wheel is can be turned 360 degrees around. Depending on it’s degrees it should output the percentage of completion to play an animation. for example ( rotation of 120degrees = 120/360 = 0.33333)
But here’s the problem. I’m reading the eulerangles, and it goes from zero up to 90degrees.
Past 90 degrees, it goes back to zero, instead of 180.
How can you bypass this, and read the amount of rotation from it’s starting rotation?
What I would do is keep track of how much the wheel was rotated by the player in the script. Trying to read and analyze a transform’s Euler angles can be problematic because for any given rotation, there are numerous possible Euler representations. For example something with this rotation: (0,0,270) is the same as (0,0,-90). The Euler angles are different, but the two rotations are the same.
You can see in Unity’s example of using Euler angles, they use the same technique:
Just do some trigonometry, this should give a percentage from 0, when the up vector of the transform is pointing down, to 50% when pointing up, and then to 100% when moving down in the other direction again. Modify as needed.
float a = Mathf.Atan2(transform.up.x, transform.up.y);
a += Mathf.PI;
a /= 2f * Mathf.PI;
a *= 100f;