Home Game Development unity – gesture affect one another

unity – gesture affect one another

0
unity – gesture affect one another

[ad_1]

right here is my two of contact operate, the primary is 2 finger contact the display and transfer the digicam;
the 2st one is zoom in-out.

the issue is it usually affect one another , when i exploit it.

like is use two finger transfer its will exclude a bit bit zoom in..

learn how to repair it??

    void touchMve()
    {
        if (Input.touchCount == 2)
        {
            Touch Tozero = Input.GetTouch(0);
            Touch Toone = Input.GetTouch(1);
            if (Tozero .section == TouchPart.Moved && Toone.section == TouchPart.Moved)
            {
                remodel.Translate(-(Tozero.deltaPosition.x + Toone .deltaPosition.x)/ 2000,
                    -(Tozero.deltaPosition.y + Toone .deltaPosition.y)/ 2000, 0);
            }
        }
    }
    void touchZoom()
    {
        if (Input.touchCount == 2)
        {
            Touch Tozero = Input.GetTouch(0);
            Touch Toone = Input.GetTouch(1);
            Vector2 Tozeroprevious =  Tozero.deltaPosition - Tozero.place;
            Vector2 Tooneprevious = Toone.deltaPosition - Toone.place;

            float outdatedTouchDistance = Vector2.Distance(Tozeroprevious, Tooneprevious);
            float PresentTouchdistance = Vector2.Distance(Tozero.place, Toone.place);
            float Offset = outdatedTouchDistance - PresentTouchdistance;
            if (Tozero.section == TouchPart.Moved && Toone.section == TouchPart.Moved)
            {
                remodel.Translate(0, 0, - Offset / 1000);
             }
        }
    }

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here