Hi all, I need to move a texture up and down on the screen based on the rotation of another object. So euler angles sound perfect considering the values are pretty linear with rotation.
The angle value progresses up to about 87, then it hangs there for a few degrees (even though the object is still visibly rotating), and then starts dropping back down. It wont read all the way up to 90, almost like there is a dead zone of 2 degrees around 90.
Anyone know how to solve this, or is there another way to get any sort of linear value for a rotation around 1 axis?
Euler angles have some shortcomings (which is why they are not generally used for internal math in game engines, Quaternions are preferred for that), and since there are multiple ways to represent a specific rotation, you are not guaranteed to get continuous results for rotation along any axis.
However, you should be able to calculate the rotation around an arbitrary axis yourself. This should give you the angle of a vector around the z-Axis for example (un-tested):
var vector = transform.direction;
var angle : float = Mathf.Atan2(vector.x, vector.z) * Mathf.Rad2Deg;
I ended up just reorienting my object so that 90 degrees (y-axis) wasn't within the range of readings that I needed (I'm using forward for the primary direction instead of up now). I wouldn't call this an answer, but a workaround. I'd still like to know why this happens, but I also need to move on due to tight deadlines!
Thanks for all of the replies, and if you have more info, I'd love to hear it!