title: How can I get XY Euler angles from a direction?
body: <p>I have a first person camera controller implemented as follows:</p>
  
  <pre><code>float rotSpeed = 20.0f;
  
  xRotation += deltaPos.y * rotSpeed * Time.deltaTime;
  yRotation += deltaPos.x * -rotSpeed * Time.deltaTime;
  
  while(xRotation &gt; 360.0f) xRotation -= 360.0f;
  while(xRotation &lt; 0.0f)   xRotation += 360.0f;
  
  while(yRotation &gt; 360.0f) yRotation -= 360.0f;
  while(yRotation &lt; 0.0f)   yRotation += 360.0f;
  
  cam.transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
  </code></pre>
  
  <p>I would like the camera to be able to snap to some target in 3D space.</p>
  
  <p>If I use transform.LookAt(target), the camera controller will just snap the view right back where it came from, and I can't set xRotation and yRotation from the camera's rotation after the call to LookAt(), because LookAt() sometimes produces a Quaternion with a Z rotation.</p>
  
  <p>So how can I find the X and Y rotation that would be required to point the camera at some target?</p>