Dude... Relax - this forum is less "perused".
Quote: "Can it be used to create a sphere around a point in space, which returns the object number of any object that enters the sphere? Thanks."
I don't know. But I do know you could make and invisible sphere and set it up for collision - and then get the object # of the last collision and the X,Y,Z also. There is the possibility of "skip" though where the object is outside - and next position is inside. That will get ignored. On trick I use which isn't perfect but pretty decent - is if I have a fast mover - and the timing suggests moving it "100", I'll divide that value I need to move it by like 10 and just move it in steps checking for collision each spin. (This isn't an onscreen/sync - its a quick "object move" but in tiny pieces to make better chance of hitting the object I'd like it to register. You also can cheat this with invisible object that is "oversized" (Like bullets are obviously tiny - but I've sometimes made invisible JAVELINS just to decrease the chance of "skip". (where the collision doesn't register.)
For the distance thing - make a vector...
`-----------------------------------------------------
` Vector Reserved for Distance
`-----------------------------------------------------
#CONSTANT cnVectorDistance=1
i=make vector3(cnVectorDistance)
then use
`------------------------------------------------------------------------------------------------------------
Function Distance(xpos#,ypos#,zpos#,objnum)
`------------------------------------------------------------------------------------------------------------
` SQRT Way
`nx#=object position x(objnum)-xpos#
`ny#=object position y(objnum)-ypos#
`nz#=object position z(objnum)-zpos#
`distance#=sqrt((nx#*nx#)+(ny#*ny#)+(nz#*nz#))
` VECTOR WAY
nx#=object position x(objnum)
ny#=object position y(objnum)
nz#=object position z(objnum)
set vector3 cnVectorDistance, xpos# - nx#, ypos# - ny#, zpos# - nz#
distance# = length vector3(cnVectorDistance)
ENDFUNCTION distance#
`------------------------------------------------------------------------------------------------------------
The vector way is faster. I've tested it against the square root math method.
But I'm always hering "Use a grid" to minimize searching. This means - only check the distance of the "objects" you suspect a collision with that are "within" the resonable x/y/z range of your sphere... like X>min and X<max and Y>min and y<max and Z>min and Z<max (For example) because in short - you want to check as few objects as possible. Looping is slow in DPRO.
Ray Casting works pretty good... and is Sphere Cast works like Ray Cast - than this would probably be WAY faster - but You'll likely need to set up a little test app to try it out seeing how no one has responded to you prior to me.