hi Masqutti
If dummy.ObjNum is close to coolObject.ObjNum
the distance is way off. For example use spacekey to randomize the positions then see if you can get the yellow cube next to the red cube. It will say distance 50.0 or higher right next to it.
That means the vertexes should be very close, because coolObject.ObjNum is very close to dummy.ObjNum.
here is the code that shows it should be working
Also I got it were it gets the lowest vertex position , but still problems.

Notice the dummy.Distance is way off compared to dummy.Distance2
rem turn off cam
autocam off
rem sync on
sync on
rem turn backdrop on
backdrop on
smallest as float
rem make data types
type CoolObjectType
ObjNum as integer
X as float
Y as float
Z as float
VX as float
VZ as float
Distance as float
endtype
global coolObject as CoolObjectType
type DummyType
ObjNum as integer
X as float
Y as float
Z as float
Distance as float
Distance2 as float
endtype
global dummy as DummyType
rem make objects
Make_Object()
Make_Dummy()
rem position the camera
position camera 0,200,0
point camera 0,0,0
do
dummy.Distance2 = sqrt((dummy.X-coolObject.X)^2+(dummy.Z-coolObject.Z)^2)
position object coolObject.ObjNum,coolObject.X,coolObject.Y,coolObject.Z
rem lock the object
lock vertexdata for limb coolObject.ObjNum,0
rem loop through the vertexes
for i = 0 to get vertexdata vertex count()-1
rem get the vertex x position and put it in coolObject.VX
coolObject.VX = get vertexdata position x(i)
rem get the vertex Z position and put it in coolObject.VZ
coolObject.VZ = get vertexdata position z(i)
rem make a simple 2D distance formula for now
rem this distance formula gets the a point from the object to the vertexes
rem get smallest distance from vertex
smallest = 100
dummy.Distance = sqrt((dummy.X-coolObject.VX)^2+(dummy.Z-coolObject.VZ)^2)
if dummy.Distance < smallest
smallest = dummy.Distance
endif
next i
rem i'm done with the object unlock it
unlock vertexdata
if spacekey()=1
rem randomize position
dummy.X = rnd(100)
dummy.Z = rnd(100)
position object dummy.ObjNum,dummy.X,dummy.Y,dummy.Z
endif
rem update distance
set text font "Arial"
set text size 15
text 20,20,"dummy.Distance from vertexes : " +str$(abs(dummy.Distance))
text 20,40,"smallest vertex distance: " +str$(smallest)
text 20,60,"dummy.Distance2: " +str$(abs(dummy.Distance2))
sync
loop
function Make_Object()
coolObject.ObjNum = 1
coolObject.X = rnd(100)
coolObject.Y = 0
coolObject.Z = rnd(100)
make object cube coolObject.ObjNum,1
color object coolObject.ObjNum,rgb(255,0,0)
position object coolObject.ObjNum,coolObject.X,coolObject.Y,coolObject.Z
endfunction
function Make_Dummy()
dummy.ObjNum = 2
dummy.X = 10
dummy.Z = 10
make object cube dummy.ObjNum,1
color object dummy.ObjNum,rgb(255,255,0)
position object dummy.ObjNum,dummy.X,dummy.Y,dummy.Z
endfunction
darkvee