title: Rotate objects with touch in unity
body: <p>I want to rotate an object with touch in unity. I touch is moved left object should rotate leftward as long as user holds the touch and vice versa.
  My code rotates the object correctly as long as touch is moved leftward or rightward. Later if touch movement is stopped and hold, object starts rotating rightward. Here is what i have tried. </p>
  
  <pre><code>{
  if (Input.touchCount &gt; 0)
      {
          touch = Input.GetTouch(0);
          if (touch.phase == TouchPhase.Began)
          {
              oldTouchPosition = touch.position;
          }
          else if (touch.phase == TouchPhase.Moved)
          {
              if (touch.deltaPosition.x &gt; 10f)
              {
                  rotateLeftward = false;
                  rotateRightward = true;
              }
  
              else if (touch.deltaPosition.x &lt; 10f)
              {
                  rotateRightward = false;
                  rotateLeftward = true;
              }
          }
  
  
  
          if(rotateLeftward == true )
          {
              RotateLeftWard();
          }
          else if (rotateRightward == true)
          {
              RotateRightWard();
          }
      }
  }
  
  
  void RotateLeftWard()
  {
      transform.rotation = Quaternion.Euler(0f, 1 * keepRotateSpeed, 0f) * transform.rotation;
  }
  
  void RotateRightWard()
  {
      transform.rotation = Quaternion.Euler(0f, -1 * keepRotateSpeed, 0f) * transform.rotation;
  }
  </code></pre>