title: Limiting vertical camera rotation
body: <p>I've seen multiple threads on this topic, although none of those solutions have worked for my current script. I have my camera set up so it rotates when the right mouse button is being held down and dragged. My camera moves with the WASD keys.</p>
  
  <pre><code>    if(Input.GetMouseButtonDown(1))
      {
          // Get mouse origin
          mouseOrigin = Input.mousePosition;
          isRotating = true;
      }
  
      if (isRotating)
      {
          Vector3 pos = cameraMain.ScreenToViewportPoint(Input.mousePosition - mouseOrigin);
  
          transform.RotateAround(transform.position, transform.right, -pos.y * turnSpeed);
          transform.RotateAround(transform.position, Vector3.up, pos.x * turnSpeed);
      }
  </code></pre>
  
  <p>The error I have with this is that the camera vertically rotates freely. I want to know how to apply a limit to this rotation without changing the effect this code has on the camera.</p>