Game Object: linearVelocity

linearVelocity
  • Get/set the object's initial Linear Velocity

Type:

  • float list [ x, y, z ]
    • x = linear velocity on the world x-axis
       
    • y = linear velocity on the world y-axis
       
    • z = linear velocity on the world z-axis
Range:
  • 0.00 to 10,000.00
Note:
  • Physics Type: Rigid Body and Dynamic.
Sample Code

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

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

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

# get the linear Velocity
linVel = obj.linearVelocity

Sample Code

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