Class KX_GameObject -- Blender Game Engine 2.49b



 
  



getVectTo

getVectTo(pos)

Returns the distance and vector to a game object or a point.

pos:
Type:  KX_GameObject
   or
   point (world coordinates -- example [ 2.0, 3.2, 5.0])

Return type:  list [ distance, globalVector, localVector ]

distance:
distance to the game object or point
Type:  float

globalVector:
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

localVector:
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 controller
controller = GameLogic.getCurrentController()

# get game object controller attached to
obj = controller.owner

# get the current scene
scene = GameLogic.getCurrentScene()

# get a list of the objects in the scene
objList = scene.objects

# get game object named "Box"
box = objList["OBBox"]

# get the distance and vector to box
vectTo = obj.getVectTo(box)

 
Game developers can use the game engine to create casual video games, first and third person shooters, role playing games, racing simulations and more. The game engine can be used to make both 2D games and 3D games.  Beginning game developers will only need basic knowledge of game design and programming to create rich and complex game models with photo realistic textures to add detail to the graphics of the video game.  Today's games need more than good looking low polygon game models.  Use normal maps and photo realistic textures to create high quality game models.