This site uses strictly necessary cookies. More Information

X- Home /

# Euler angles have a dead zone near 90?

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?

Thanks!

I've never observed anything like that. Can you edit your post to include the code that sets and reads back the rotation for the object?

$$anonymous$$y guess is that your object is rotated already in 1 or more axis. You probably mixed Transform.rotation and Transform.localRotation Take a look at http://en.wikipedia.org/wiki/Euler_angles

Thanks for the replies. To recreate, add the $$anonymous$$ouseLook script from the Component $$anonymous$$enu -> Camera-Control group. Lower sensitivity to 1, and set the minimum and maximum properties to -360 and 360 respectively.

Display the eulers and watch the y coordinate: Debug.Log(transform.eulerAngles);

When you look down and the camera approaches 90 degrees, you will see that the y euler rarely goes above 87.5ish. Sometimes it snaps right onto 90, but other times it just hangs out at 87.x

I observed the same behaviour as well, I'm adding a small value to the x and y components (z is not touched and stays 0) of a Transform's eulerAngles every frame (navigation code using angular velocity). When setting the x component to 89.9 for example and reading it back, the value became 90.0.

**Answer** by jonas-echterhoff
·
Jan 25, 2011 at 09:23 AM

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 just could not get this to work. I tried multiple directions (up forward, right) and every combination of x,y x,z y,x y,z, z,x z,y for each direction. Nothing led me to a value that linearly worked on the x axis. All values that changed with x rotations also changed with z rotations.

**Answer** by Jade
·
Jan 26, 2011 at 03:33 AM

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!

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.