Game Object: localLinearVelocity

localLinearVelocity
  • gets/sets the object's local Linear Velocity

Type:

  • float list [ x, y, z ]
     
  • x = linear velocity on the game object's x-axis
     
  • y = linear velocity on the game object's y-axis
     
  • z = linear velocity on the game object's z-axis
Note:
  • Physics Type: Rigid Body and Dynamic.
Sample Code

################## get the game object's local linear velocity
 
# import bge
import bge

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

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

# get the local linear Velocity
linVel = obj.localLinearVelocity

Sample Code

################## set the game object's local linear velocity
 
# 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 local linear velocity
obj.localLinearVelocity = [ 0.0, 0.0, 10.0]