My Code is as follows:
foreach (Touch touch in Input.touches) {
switch (touch.phase) {
case TouchPhase.Began:
touchPosition = Camera.main.ScreenToWorldPoint (Input.mousePosition);
offset = touchPosition - GOCenter;
break;
case TouchPhase.Moved:
touchPosition = Camera.main.ScreenToWorldPoint (Input.mousePosition);
newGOCenter = touchPosition - offset;
newGOCenter.y = 0.0f;
newGOCenter.z = 0.0f;
gameObject.transform.position = newGOCenter;
gameObject.transform.position = new Vector3 (
Mathf.Clamp (gameObject.transform.position.x, -boundary.xMinMax, boundary.xMinMax),
0.0f,
0.0f
);
break;
default:
break;
}
}
What i am doing is i am moving the player left and right along x-axis by dragging in the screen.
When i drag/move the player with one finger then it works as expected.
But when i keep another finger in the screen and take out the first finger from the screen the player comes of the second finger.
I want the player to be moved from the place where it was left instead of coming to the second finger.
[I have done] - disabled multiTouch but it does not worked. - user fingerIndex