@name Magnet
@inputs N1 N2
@outputs 
@persist Obj1:entity Obj2:entity C Count
@trigger all
interval(20)
Owner=entity():owner()
Aim=Owner:aimEntity()
if(N1&Aim){Obj1=Aim print("setting Object 1")}
if(N2&Aim){Obj2=Aim print("setting Object 2")}

Opos1=Obj1:pos()
Opos2=Obj2:pos()
Dist=Obj1:pos():distance(Obj2:pos())
R=Obj1:radius()+Obj2:radius()+5
XYZ=((Opos1-Opos2)/2)+Opos2  #calculates the mid point between 2 objects
C=1
Count=2
while(C<=Count&Obj1&Obj2&Dist>R){
    if(C==1){Obj=Obj1}
    if(C==2){Obj=Obj2}
E=Obj
Force=1
E:applyForce((Force*((XYZ-E:pos())+vec(0,0,0))-E:vel())*E:mass()+E:owner():vel()*10)
C++
}
