# Inspector Euler angles deviates from Euler angles in code

Hi everyone,

I'm trying to clamp the rotation over the X axis(tilt) so you can not rotate further up than straight up and not further down then straight down. The problem is that the clamp angle seems to be between -90 and 90 if you look at the inspector but if you debug.log the euler angle, it shows that the angle is actually below 90 for every camera tilt downwards. To make it a little bit more clear, if you look straight ahead, the inspector shows 0 and the debug also shows 0. If you look straight down, the inspector shows 90 and the debug also shows 90. If you tilt even further "downwards", the inspector shows 180, but the debug log shows 0 again. See the screenshot below for an indication.

This is the code I use to show the euler angle.

```
Vector3 camEuler = camT.rotation.eulerAngles;
Debug.Log("cam angle " + camEuler.x);
```

In which camT is the camera transform. Does someone know why this happens?

Kind regards,

Yorick

Reference for pan,tilt,roll:

**Answer** by tanoshimi
·
Jan 06, 2017 at 05:02 PM

There are many ways to express the same rotation: a rotation of 180 degrees around the y axis is the same as a rotation of 180 degrees around the x axis followed by 180 degrees around the z axis, for example.

Your Debug.Log only looks at the x component of the rotation but, if you look at the eulerAngle Vector as a whole, you'll probably just see that they are equivalent expressions of the same rotation.

To add to this: rotations are *not* stored as xyz angles. So the Inspector is your xyz settings translated into a Quaternion, then translated back to show in the Inspector.

Inspector values aren't supposed to match the ones you set. My long explanation is at taxesforcatses-dot-com/vectorW/ch4Rotation.pdf, in section 4.

So it should actually be better to clamp the quaternions? I don't know exactly what the components of a quaternion are so I have no idea what to enter. For Euler it could be quite simple, just clamp the x between -90 and 90 but thanks to the conversions I can not do that. As far as I know quaternions contain a vector and scalar but I have no idea what kind of units the components are and how they relate to each other.

I will take a look at your document, thanks

### 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.