I need a distance command to insert into my code to reposisition an object if the two objects are close, here is my code. I use darkbasic pro
make matrix 1,100,100,25,25
make camera 1
position camera 1,1,20,1
make object box 1,10,10,10
position object 1,0,0,0
make object sphere 2,10
position object 2,100,0,100
point camera 1,Object Position x(2),Object Position y(2),Object Position z(2)
do
`controls for camera
if upkey()=1 then move camera 1,.2
if rightkey()=1 then turn camera right 1,.1
if leftkey()=1 then turn camera left 1,.1
if downkey()=1 then move camera 1,-.2
`move object1 to object2
Point Object 1,Object Position x(2),Object Position y(2),Object Position z(2)
move object 1,.1
`here is where i need help, i want it to get the distance of the objects and if it is 0 then to move object 2 to a random spot on the matrix
loop
i tried the get distance functions in the code base, but couldnt get them to work
EDIT
asked my brother and got it to work
my script is
Dist=Sqrt((Object Position X(1)-Object Position X(2))^2+(Object Position Y(1)-Object Position Y(2))^2+(Object Position Z(1)-Object Position Z(2))^2)
if dist<1 then position object 2,rnd(100),0,rnd(100)