Game Object: setLinearVelocity

setLinearVelocity(force, local)
  • Sets the linear velocity of a game object.

force:

  • Force to be applied along an axis.
  • Type:  float list  [fx, fy, fz]
local:
  • Select local (game object) or world axis to apply force.
  • Type:  boolean
  • Local axis: 1 or True
  • World axis: 0 or False
Note:
  • Physics Type: Rigid Body and Dynamic.
Sample Code

################## set the linear velocity
  

# import bge
import bge

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

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

# apply a force of 5.0 to x-axis
force = [ 5.0, 0.0, 0.0]

# use game object axis
local = True

# set linear velocity
obj.setLinearVelocity(force, local)