How can I find the distance between two objects in real time?
I believe there is a function for that included in mathUtils or GameLogc modules,
I just use this function for the x/y distance
def findDistance(p1, p2):
from math import sqrt
a = p2[0] - p1[0]
b = p2[1] - p1[1]
c = sqrt(pow(a,2) + pow(b,2))
return c
ok thanks alot!!
either
from Mathutils import Vector
...
p1 = Vector( x,y[,z] )
p2 = Vector( x,y[,z] )
distanceFromP1toP2 = (p2 - p1).magnitude
or
...
distance = object1.getDistanceTo(object2)