Game Object: position

position
  • Get/set the game object's world position

Type:
  • float list [ x, y, z]
    • x: position on the world x-axis
       
    • y: position on the world y-axis
       
    • z: position on the world z-axis
Sample Code

################## get the game object's world position
 
# import bge
import bge

# get controller
cont = bge.logic.getCurrentController()

# get object that controller is attached to
obj = cont.owner

# get the world position
posWorld = obj.position

Sample Code

################## set the game object's world position
 
# import bge
import bge

# get controller
cont = bge.logic.getCurrentController()

# get object that controller is attached to
obj = cont.owner

# set the game object's world position
obj.position = [ 2.0, 0.0, 1.0 ]