Blobs controling shapes

I have a problem. Been trying to solve it for week now.

Heres the overall concept of the Patch:

4 blobs are tracked. Whenever one of these blobs makes a recognizable shape (that module works well) it’s center is sent so that it can control an object (in the example a cloud).

Problem: Blobs come and go, and blob IDs don’t help. I want any blob to be able to control any cloud. As long as it’s visible and no one else is controling it.

I tried to use each blob center to search for the nearest cloud, and control that. But it doens’t work properly…

Here is a patch, think you can help?

I wan’t a blob to control the nearest shape. IF the blob is gone, the shape that was being controled stays in place (does not search for another blob) until it fades away.

how can I keep the clouds from shufling everytime a blob disapears ?

Thanks in advance.

blobs_and_clouds.zip (49.9 kB)

its not exactly clear to me, i guess you want a simple drag and drop gesture? so as a blob appears, you want to draw something there and move it along the blob. if the blop is deleted, the graphic of the blob fades out?

Yes.But If the blob disapears the graphic stays in place for a few seconds. If no other blob appears to move it then it just fades away.

The problem arrives with multiple blobs.