Tag Info

Calculate the dot product to determine how close two vectors are. The dot product is 1 when they are exactly the same, -1 when they are exactly opposite, 0 when they are perpendicular, and decimal values when partway.
So take the current direction, the target direction, then Vector3.Dot() and check if greater than .9 (or whatever threshold you decide looks ...

First, it won't solve your problem, but there are a few general problems with your code.
The conditions for your if branch will always be true if transform.localEulerAngles.x >= 0 and <= 360. The > 270 part is redundant since if x is less than 270, it is still possible to be >= 0.
If x is 0 and lookAxisX is > 0, then adding -lookAxisX will make x < ...

jhocking's answer about dot product is the right answer to the question, but if you are rotating your object over time to face the right direction, inside that function you must be calculating how much you have left to rotate so that you know what direction to rotate and so that you don't rotate too far and overshoot.
That means that inside that function, ...

Something like this:
transform.position = player.transform.position - player.transform.forward * distance;
transform.LookAt(player.transform);
where float distance is the distance of camera form player
Consider also the solution 2 : Make camera child of player and in your player die script , you can "deatach" camera from player object
transform.parent ...

I personally never calculate an angle like that. I like to work with vectors, it might be slightly less efficient but this way you can do it step by step, it gets more readable and easier to understand.
So what is a vector? A vector is essentially a direction and a magnitude together. Often in games it is used as a position data structure too but ...

You can always try to use the clamp method:
Ref: http://docs.unity3d.com/ScriptReference/Mathf.Clamp.html
Example
transform.localEulerAngles = new Vector3(Mathf.Clamp(transform.localEulerAngles.x, 0f, 90f), 0, 0);
**This is just a push in the right direction (above is untested)

Exerpt from the 3D CSG module I wrote for my engine. You should be able to derive from this easily enough.
SOLID_C *Rotate(const V3 &axis,const T angle)
{
T a=radians(angle),c=cos(a),s=sin(a);
V3 rt[3],m[3],mt[3],ax=((V3)axis).normalise(),t=ax*(1.-c);
rt[0][0]=c+t[0]*ax[0]; rt[0][1]=0+t[0]*ax[1]+s*ax[2]; rt[0][2]=0+t[0]*ax[2]-s*ax[1];
...