Posted: 7th Sep 2003 20:07
Below is a function which calculates the distance between two objects.You can use it to make for example a monster attack you depending on how close you are.It is generally for beginners and uses pythagoras' theorem.

function distance(obj1,obj2)
dist=sqrt(((object position x(obj1)-object position x(obj2))*(object position x(obj1)-object position x(obj2)))+((object position z(obj1)-object position z(obj2))*(object position z(obj1)-object position z(obj2))))
endfunction dist
Posted: 7th Sep 2003 22:38
Unfortunately your code does not allow for objects at different heights (y axis).

Do a search on this forum and various functions are presented but best, and fastest is Pneumatic's which can be found here:

http://www.thegamecreators.com/?m=forum_view&t=11638&b=1

It uses those horrible vector commands but it is much faster than using sqrt.
Posted: 8th Sep 2003 1:43
i never got the hang of vector 3 stuff