BDAnimationModules.MouseAimLight.ReturnTurret C# (CSharp) Method

ReturnTurret() private method

private ReturnTurret ( ) : void
return void
        private void ReturnTurret()
        {
            float returnSpeed = Mathf.Clamp (rotationSpeed, 0.1f, 6f);
            bool yawReturned = false;
            bool pitchReturned = false;
            turretZeroed = false;
            float yaw = yawTransform.localRotation.Roll() * Mathf.Rad2Deg;
            float pitch = pitchTransform.localRotation.Yaw () * Mathf.Rad2Deg;

            //Debug.Log ("Pitch: "+pitch*Mathf.Rad2Deg+", Yaw: "+yaw*Mathf.Rad2Deg);

            if(yaw > 1 || yaw < -1)
            {
                if(yaw > 0)
                {
                    yawTransform.localRotation *= Quaternion.AngleAxis(-Mathf.Clamp(Mathf.Abs (yaw)/2, 0.01f, returnSpeed), yawAxis);
                }
                if(yaw < 0)
                {
                    yawTransform.localRotation *= Quaternion.AngleAxis(Mathf.Clamp(Mathf.Abs (yaw)/2, 0.01f, returnSpeed), yawAxis);
                }
            }
            else
            {
                yawReturned = true;
            }

            if(pitch > 1 || pitch < -1)
            {
                if(pitch > 0)
                {
                    pitchTransform.localRotation *= Quaternion.AngleAxis(Mathf.Clamp(Mathf.Abs (pitch)/2, 0.01f, returnSpeed), pitchAxis);
                }
                if(pitch < 0)
                {
                    pitchTransform.localRotation *= Quaternion.AngleAxis(-Mathf.Clamp(Mathf.Abs (pitch)/2, 0.01f, returnSpeed), pitchAxis);
                }
            }
            else
            {
                pitchReturned = true;
            }
            if(yawReturned && pitchReturned)
            {
                yawTransform.localRotation = Quaternion.Euler(0,0,0);
                pitchTransform.localRotation = Quaternion.Euler(0,0,0);
                turretZeroed = true;
            }
        }