**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).

### People who like this

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

https://docs.unity3d.com/ScriptReference/Quaternion.LookRotation.html

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.

### Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta on June 13. **Please note, Unity Answers is now in read-only so we can prepare for the final data migration.**

For more information and updates, please read our full announcement thread in the Unity Forum.