Gather objects in one point

Hello! Is it possible to gather rigidbodies in one point, so they move to each other and meet in point, average for all of them. Just like magnets… I am trying different ways, but still can’t get it.

Searching forums, I found a nice workable code for magnet-like effect, but it gather all objects around one (for which this code is applied). So it’s like a “magnetic bomb”. Not what I need exactly… Anyway, here is it:

var blastForce = 0;
var blastRadius = 10;
var implode = true;

 function FixedUpdate () {
     var things : Collider[] = Physics.OverlapSphere(transform.position, blastRadius);
     for (i=0; i<things.length; i++){
         if (things_.attachedRigidbody && things*.attachedRigidbody != rigidbody){*_

var offset : Vector3 = (transform.position - things*.transform.position);*
things_.attachedRigidbody.AddForce(offset/offset.magnitude * -blastForce);

function Update() {
var key1 = Input.GetKey(“1”);
var key2 = Input.GetKey(“2”);
if (key1 && implode){
implode = false;
blastForce = -100;
if (key2 && !implode){
implode = true;
blastForce = 50;
Thank you for answering!

Couldn’t you just average the positions of all the points and then apply a force on all the objects towards that point?

something like this:

float blastForce = 5.0f;
Vector3 total =;
for(thing in things)
   total += thing.transform.position;
Vector3 center = total/things.length;
for(thing in things)
     thing.attachedRigidbody.AddForce((center - thing.transform.position)*blastForce);

I think that’d do it.