TGC Codebase Backup



Distance function by cpltiffer

7th Jun 2004 9:58
Summary

Function for distance of objects



Description

I've used an old formula and put it into a function to save the user of my snippet time.
After inserting this into your program you can test distances between object by using the command distance(object 1,object 2)



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    function distance(obja.objb)
xa#=object position x(objba)
ya#=object position y(obja)
za#=bject position z(obja)

xb#=object position x(objb)
yb#=object position y(objb)
zb#=bject position z(objb)

distance#=sqrt((xa#-xb#)^2 + (ya#-yb#)^2 + (za#-zb#)^2)
endfunction distance#