Pinch/pan libraries available?

302 views
Skip to first unread message

John Grden

unread,
Feb 17, 2011, 12:02:53 AM2/17/11
to unity3d-d...@googlegroups.com
I've been looking around to see if there are any libraries available (c# preferably) for doing pinch/zoom/pan gestures on iPad/iPhone

Does anyone know of any they can pass along?

--
[  JPG  ]

John Grden

unread,
Feb 17, 2011, 12:20:37 AM2/17/11
to unity3d-d...@googlegroups.com
I just hadn't used the word "pinch" until now:

http://forum.unity3d.com/threads/15603-Pinch

There it is!

John
--
[  JPG  ]

John Grden

unread,
Feb 17, 2011, 1:29:47 AM2/17/11
to unity3d-d...@googlegroups.com
http://forum.unity3d.com/threads/15603-Pinch?p=502047&viewfull=1#post502047

here's my condensed version:
if ( iPhoneInput.touchCount == 2 )
{
iPhoneTouch touch1 = iPhoneInput.GetTouch( 0 );
iPhoneTouch touch2 = iPhoneInput.GetTouch( 1 );

// Find out how the touches have moved relative to eachother:
Vector2 curDist = touch1.position - touch2.position;
Vector2 prevDist = (touch1.position - touch1.positionDelta) - (touch2.position - touch2.positionDelta);

float touchDelta = curDist.magnitude - prevDist.magnitude;

// move camera in world coordinates
//Camera.main.transform.position -= new Vector3(0, 0, touchDelta * .5f);

// translate along local coordinate space
Camera.main.transform.Translate(0,0,touchDelta*.5f);
}
--
[  JPG  ]
Reply all
Reply to author
Forward
0 new messages