Saturday, October 15, 2022
HomeGame Developmentunity - gesture affect one another

unity – gesture affect one another


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

the issue is it typically affect one another , when i take advantage of it.

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

learn how to repair it??

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

            float oldTouchDistance = Vector2.Distance(Tozeroprevious, Tooneprevious);
            float CurrentTouchdistance = Vector2.Distance(Tozero.place, Toone.place);
            float Offset = oldTouchDistance - CurrentTouchdistance;
            if (Tozero.part == TouchPhase.Moved && Toone.part == TouchPhase.Moved)
            {
                remodel.Translate(0, 0, - Offset / 1000);
             }
        }
    }

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments