finding the angle that the normal makes with the horizontal

Viewed 52

In unity, I would like to know if there is a way to calculate what angle the camera/headset is making with the horizontal.

I'm totally new to unity (I'm 13), so please go easy on me.

I was trying to calculate the angle like this:

float zAngle = (float)Mathf.Asin(headset.transform.forward.z);

My logic is this: If the forward vector of a headset is the normal vector, it has a length of 1 (because it's a unit vector).

sin(angle) =       zComponent of forward vector
             ----------------------------------------------
             hypoteneuse =1 (our unit vector normal length)

angle = arcsin(z)

But when I rotate the camera (which is hooked up to the headset variable above), by 30 degrees along z axis, headset.transform.forward.z remains 1 (and it should be less than 1).

Right? What am I doing wrong here?

0 Answers
Related