Limit draggable objects to exactly 1

Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.

How do I…

Limit the user to only being able to drag one draggable object at a time

What is the expected result

A user touches more than one draggable object at the same time, only the first object touched is draggable

What is the actual result

User is able to drag all draggable objects at the same time

You could make scene variable call it DragDetect
If ANY object is dragged set that var to true
Now if DargDetect is true
Object is not dragged then disable its drag behavior

When DragDetect is false enable dargg behavior for all objects

This won’t work because it also disables the behaviour of the one you want to drag, ie the one you’ve just touched

If var becomes true only when you are dragging object

And while its true disable behavior for objects that are NOT being dragged

Then how it can disable behavior for one that is being dragged?

Maybe I’m misunderstanding, but do you mean something like the below (numbers is the group of draggable objects)

Even without this BS i am unable to drag more than 1 object
EVEN when they overlap and i click multiple at the same time
BUT just for sake of argument i am changing animations of ballz depending on if their drag behavior is on or off
And somehow it indicates that it should NOT allow more than 1 object to be dragged

Go ahead and touch my ballz then try to drag them

Thanks!

I played with your ballz and it felt good

Are you testing this on a device with a touch screen? Being able to use multiple touch is different than a single mouse click.

No and that’s why probably i was not able to drag more than 1 object by default
But still my method proves to be working i guess

@Keith_1357 @ZeroX4 testing on android device - solution does work, but if a user happens to press on two objects at EXACTLY the same time, they will still both become draggable. Maybe it’s an edge case

Easy fix would be to pick nearest object to something or pick random object and to disable drag behavior for it
IN THAT CASE