Script Reference: Camera.ScreenToWorldPointif (Input.touchCount > 0)
{
Touch touch = Input.GetTouch(0);
if (touch.phase == TouchPhase.Moved)
{
Vector3 position = new Vector3(
touch.position.x,
touch.position.y,
Camera.Main.nearClipPlane
);
transform.position = Camera.Main.ScreenToWorldPoint(position);
}
}
}