**Question**by Guenter123987 · Feb 14, 2017 at 03:51 PM · c#rotationscripting problemvector3scripting beginner

# Searching a function to get the rotation of one Vector3 in relation to another

I need it to get the rotation of a 3rd Person Camera in relation to its target. If the rotation around the X axis is near to 90 degrees, the camera will be stopped rotating upwards (and the other way around with -90 degrees).

**Answer** by toddisarockstar
·
Feb 16, 2017 at 01:44 AM

Thank you for your help. Although I looked around in the API, I didn't find this function. But how do I get the X rotation of the given Quaternion? (I'm a scripting noob, I know.)

with rotations there is actually a difference between Quaternion and Euler Angles. which confuses everyone at first. usually when you are writing code its easiest to deal with Euler angles for calculations if you want simple numbers between 0 and 360.

so most of the time if you just want to know a rotation on an axis you would acually say:

```
transform.eulerAngles.x
```

Quaternion numbers can actually go higher than 360 and lower than 0 but can solve issues of some things like spinning the wrong way to get to a rotation. its kinda weird.

for now I recommend sticking to euler angles in your code whenever you can! its stored as a Vector3

if you are new its very important to know that any time you want Direction between two points you simple subtract the two Vector3 locations and it represents your direction. no need for a function for it. once you have that you can convert to rotation.

```
float myx;
//get rotation that makes character look up and down....
myx=transform.eulerAngles.x;
print(myx);
//get rotation that makes character look left and right is....
// transform.eulerAngles.y;
//get rotation that makes character fall over sideways is....
// transform.eulerAngles.z
```

Also thank you for your comments. They'll help me a lot.

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