What do the objects represent? What happens when then reach each other? Are the objects spread out? Are there teams or is it just a free for all? Would multiple objects lock onto the same closest object?
All of that matters. If one object targets another would the other target it? Or do they continuely run around chasing the closest object?
If you don’t have a lot of objects then you could stick a second object to each one. Then you wouldn’t need to save the location. If there are a lot, you could use variables.
Object2 would be stuck to each object1 with the sticker behavior.
Pick object1
Pick object2
Apply force to object1 towards object2
The question is how do they get picked. Continuesly?
You could use a for each object
For each obj1
----Pick nearest obj2 from obj1 x, obj1 y
----Apply force on obj1 towards obj2
I played around with this concept.
It uses a scene variable called counter.
At the beginning
—for each obj1
-------create obj2 at obj1 x, obj1 y
--------set ID of obj1 to counter
--------set ID of obj2 to counter
--------counter +1
For each obj1
----ID of obj2 ≠ ID of obj1
----Pick nearest obj2 from obj1 x, obj1 y
----Apply force on obj1 towards obj2
The ID was needed to ignore the obj2 attached to obj1.