Game Object: worldLinearVelocity

worldLinearVelocity
  • gets/sets the game object's world Linear Velocity

Type:

  • float list [ lx, ly, lz ]
  • lx: linear velocity on the world x-axis
  • ly: linear velocity on the world y-axis
     
  • lz: linear velocity on the world z-axis
Note:
  • Physics Type: Rigid Body and Dynamic.
     
  • Linear Velocity: Velocity (speed) in a straight line.  Distance the game object moves per unit of time.
Sample Code

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

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

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

# get the world linear velocity
linVel = obj.worldLinearVelocity

Sample Code

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