title: How to stop Roll Rotation in Mouse Look Script
body: <p>I am using FPS in Unity3D and I want only Pitch and Yaw. After some moves my Mouse Look Script start Rotating around z-axis (i.e. ROLL). How to stop that?</p>
  
  <p>This is the Script that i am using for Mouse Look.</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class MouseLooking : MonoBehaviour
  {
  
      float sensitivityX = 10f;
      float sensitivityY = 10f;
      public float minimumX = -360;
      public float maximumX = 360;
      public float minimumY = -60;
      public float maximumY = 60;
      public float delayMouse = 3;
      public float noiseX = 0.1f;
      public float noiseY = 0.1f;
      public bool Noise;
  
      private float rotationX = 0;
      private float rotationY = 0;
      private float rotationXtemp = 0;
      private float rotationYtemp = 0;
      private Quaternion originalRotation;
      private float noisedeltaX;
      private float noisedeltaY;
      private float stunY;
      private float breathHolderValtarget = 1;
      private float breathHolderVal = 1;
      private TouchScreenVal touch;
  
  
      void Start ()
      {
              if (rigidbody)
                      rigidbody.freezeRotation = true;
              originalRotation = transform.localRotation;
  
              sensitivityX = sensitivityY = 10;
  
              touch = new TouchScreenVal (new Rect (0, 0, Screen.width, Screen.height));
  
      }
  
  
  
      void Update ()
      {
              sensitivityY = sensitivityX;
              //      Screen.lockCursor = true;
  
              stunY += (0 - stunY) / 20f;
  
              if (Noise) {
                      noisedeltaX += ((((Mathf.Cos (Time.time) * Random.Range (-10, 10) / 5f) * noiseX) - noisedeltaX) / 100);
                      noisedeltaY += ((((Mathf.Sin (Time.time) * Random.Range (-10, 10) / 5f) * noiseY) - noisedeltaY) / 100);
              } else {
  
                      noisedeltaX = 0;
                      noisedeltaY = 0;
              }
              #if UNITY_EDITOR
              rotationXtemp += (Input.GetAxis ("Mouse X") * sensitivityX) + (noisedeltaX * breathHolderVal);
              rotationYtemp += (Input.GetAxis ("Mouse Y") * sensitivityY) + (noisedeltaY * breathHolderVal);
              rotationX += (rotationXtemp - rotationX) / delayMouse;
              rotationY += (rotationYtemp - rotationY) / delayMouse;
              #else
  
      if (Constants.isGameOver == false) {
  
          int  count = Input.touchCount;
  
  
          if (Input.touchCount &gt; 0) {
  
              for(int i =0 ; i&lt; count ; i++)
              {
  
  
  
                  Touch touch1 = Input.GetTouch (i);
                  if ((touch1.phase == TouchPhase.Moved )  || touch1.phase == TouchPhase.Stationary) {
  
                      rotationX = rotationXtemp + ( Input.GetTouch (i).deltaPosition.x * sensitivityX* Time.deltaTime) + (noisedeltaX * breathHolderVal);
                      rotationY = rotationYtemp + ( Input.GetTouch(i).deltaPosition.y * sensitivityY* Time.deltaTime) + (noisedeltaY * breathHolderVal);
  
         //                       rotationX = rotationXtemp + (touch.OnDragDirection(true).x * sensitivityX * Time.deltaTime) + (noisedeltaX * breathHolderVal);
        //                        rotationY = rotationYtemp + (-touch.OnDragDirection(true).y * sensitivityY * Time.deltaTime) + (noisedeltaY * breathHolderVal);
  
  
  
                  }
              }
  
  
  
  
          }
          else
          {
  
              rotationX = rotationXtemp + (touch.OnDragDirection(true).x * sensitivityX * Time.deltaTime) + (noisedeltaX * breathHolderVal);
              rotationY = rotationYtemp + (-touch.OnDragDirection(true).y * sensitivityY * Time.deltaTime) + (noisedeltaY * breathHolderVal);
          }
  
  
      }
  
  
              #endif
  
              if (rotationX &gt;= 360) {
                      rotationX = 0;
                      rotationXtemp = 0;
              }
              if (rotationX &lt;= -360) {
                      rotationX = 0;
                      rotationXtemp = 0;
              }
  
              rotationX = ClampAngle (rotationX, minimumX, maximumX);
              rotationY = ClampAngle (rotationY, minimumY, maximumY);
              rotationYtemp = ClampAngle (rotationYtemp, minimumY, maximumY);
  
  
              Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.up);
              Quaternion yQuaternion = Quaternion.AngleAxis (rotationY + stunY, Vector3.left);
  
              transform.localRotation = originalRotation * xQuaternion * yQuaternion;
              breathHolderVal += (breathHolderValtarget - breathHolderVal) / 10;  
  
              #if !UNITY_EDITOR
      rotationXtemp = rotationX;
      rotationYtemp = rotationY;
              #endif
      }
  
      public void Holdbreath (float val)
      {
              breathHolderValtarget = val;
      }
  
      public void Stun (float val)
      {
              stunY = val;
      }
  
      static float ClampAngle (float angle, float min, float max)
      {
              if (angle &lt; -360.0f)
                      angle += 360.0f;
  
              if (angle &gt; 360.0f)
                      angle -= 360.0f;
  
              return Mathf.Clamp (angle, min, max);
      }
  }
  </code></pre>