Game Object: localPosition

localPosition
  • gets/sets the object's local position

Type:

  • float list [x, y, z]
     
  • x = position on the x-axis
     
  • y = position on the y-axis
     
  • z = position on the z-axis
Note:
  • Game object not parented:
    • Local position is the distance from World Axis [ 0.0, 0.0, 0.0 ]
  • Game object parented:
    • Local position is the distance from the parent
Sample Code

################## get the object's local position

# import bge
import bge

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

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

# get local position
pos_local = obj.localPosition

Sample Code

################## set the object's local position

# import bge
import bge

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

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

# set local position
obj.localPosition = [1.0, 3.5, 0.0]