Game Object: applyForce

applyForce( force, local)
  • Applies a force to the game object center.

force:
  • Amount of force applied.
  • Type:  list [ fx, fy, fz]
local:
  • Type:  boolean
  • 1 = True = Apply force using local (game object) axis
  • 0 = False = Apply force using world axis
Note:
  • Object types: Dynamic, Rigid body and Soft body
Sample Code


################## Apply force to the game object
    

# import bge
import bge

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

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

# apply force on z axis
force = [ 0.0, 0.0, 50.0]

# use local axis
local = True

# apply force
obj.applyForce(force, local)