
getVectTo(pos)
- Returns the distance and vector to a game object or a point.
- Type: KX_GameObject
or
- point [ x, y, z] world coordinates
Return Type:
- Return type: list [ distance, globalVector, localVector ]
distance:
- distance to the game object or point
- Type: float
- Vector to object/point using the global axis
- Type: list[vx, vy, vz]
vx = cosine of the angle of the vector to the world x-axis
vy = cosine of the angle of the vector to the world y-axis
vz = cosine of the angle of the vector to the world z-axis
- Vector to object/point using the local (game object) axis
- Type: list[vx, vy, vz]
vx = cosine of the angle of the vector to the object x-axis
vy = cosine of the angle of the vector to the object y-axis
vz = cosine of the angle of the vector to the object z-axis

Sample Code
################### get the distance and vector to a point
# import bge
import bge
# get controller
cont = bge.logic.getCurrentController()
# get object that controller is attached to
obj = cont.owner
# point in world coordinates
point = [ 5.0, 0.0, 10.0]
# get the distance and vector to a point
vectTo = obj.getVectTo(point)