Drag and drop Unity

Asked

Viewed 162 times

0

I’m trying to develop a simple Android game in Unity, with drag and drop function.

I used the following method to catch the object:

public void drag(){
    transform.position = Input.mousePosition;
}

Problem: Accepting simultaneous screen taps and I want you to accept just one tap at a time

How can I fix this?

1 answer

2

As you are developing for android, can treat the touches separately, so:

Touch myTouch = Input.GetTouch(0);

    Touch[] myTouches = Input.touches;
    for(int i = 0; i < Input.touchCount; i++)
    {
        //faca algo com cada touch
    }

If you only want the first input, just use index 0 in the myTouches vector.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.