Hi all! great examples, Vegas!
Here is my function of receiving a distance:
function distance(entity1,entity2)
local pos1 = (getTransformedPosition(entity1))
local pos2 = (getTransformedPosition(entity2))
return (math.sqrt(math.abs(math.pow((pos2[1]-pos1[1]),2)+math.pow((pos2[2]-pos1[2]),2) ) ) )
end
--the function call:
--1)
print(distance(player, enemy))
--2)
if distance(player, enemy) < 100 then
--
end
if it is someone useful, can lay out other functions.