Game Object: applyImpulse

applyImpulse( point, impulse, local)
  • Applies an impulse force to a point

point:
  • the point to apply the impulse force
     
  • Type:  float list [ x, y, z]
    • x = X-axis position
       
    • y = Y-axis position
       
    • z = Z-axis position
impulse:
  • Amount of force to apply
  • Type:  float list [ fx, fy, fz]
    • fx: force applied on the X-axis
       
    • fy: force applied on the Y-axis
       
    • fz: force applied on the Z-axis
local:
  • Select local or world coordinates
     
  • Type:  Boolean
    • Local: True or 1
       
    • World: False or 0
Note:
  • Object type: Dynamic and Rigid body
     
  • Impulse: Force is applied for one logic tic
     
  • Point: Can be any distance from the game object center
Sample Code

################## Apply an impulse to the game object
  

# import bge
import bge

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

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

# apply impulse to object center 
point = obj.worldPosition

# impulse of 2.0 to be applied to the z-axis
impulse = [ 0.0, 0.0, 2.0]

# impulse to be applied on the world axis
local = False

# apply impulse
obj.applyImpulse( point, impulse, local)