# Rotate a globe with swipe

Hi

This is Eric and i am new to unity 3d,I just want to rotate a globe with swiping on it.
can any body help me to do it.

Eric

Use the magnitude and direction of the swipe. Clamp the magnitude, compare the direction (if your globe should rotate around a single axis) then use transform.Rotate.

Use the magnitude for the angle of rotation then decrease that value until 0 so that your globe slows down until stopping.

``````Vector3 swipe = GetSwipe();
float mag = swipe.magnitude;
mag = Mathf.Clamp(mag, 0f,10f);
Vector3 direction;
(swipe.x < 0) ? direction = Vector3.left : direction = Vector3.right;
StartCoroutine(RotateGlobe(mag, direction));

IEnumerator RotateGlobe(float angle,Vector3 direction)
{
float __angle = angle;
while(__angle > 0)
{
transform.Rotate(__angle * Time.deltaTime * direction);
__angle-= Time.deltaTime;
yield return null;
}
}
``````

Ok this is done on top of my head so there may be a need for correction. The first part goes in a method that is called when swiping. The next one is the coroutine that performs the rotation of the globe. If someone sees an error, go ahead but I think the idea is there.