I have a large image that I’d like to allow the user to pan across by dragging their finger on the screen. I’ve been trying to make this happen using FingerGestures…but the sample solution to drag/drop doesn’t quite do it. As you can see in the attached code, it matches the transform.position of the picture to the finger touch; which means that instead of being able to pan across an image, it recenters itself over the finger with every new touch.
function FingerGestures_OnDragMove( fingerPos : Vector2, delta : Vector2 )
{
if( draggedBody )
{
// convert the finger position to world position
var distToCamera : float = Mathf.Abs( draggedBody.transform.position.z - Camera.main.transform.position.z );
var fingerWorldPos : Vector3 = Camera.main.ScreenToWorldPoint( new Vector3( fingerPos.x, fingerPos.y, distToCamera ) );
// center the object on our moving finger
draggedBody.MovePosition( fingerWorldPos );
}
}
Could I get some guidance on this from some of you more practiced in this sort of thing? Thanks!