Action: playAction

playAction(name, start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
  • Plays an action.

name:
  • Name of the action
  • Type: string
start:
  • starting frame of the action
  • Type: float number
end:
  • ending frame of the action
  • Type:  float number
layer:
  • The layer that you want to get the frame from.
  • Type:  integer
priority:
  • play this action if there isn’t an action playing in this layer with a higher (lower number) priority.
  • Type:  integer
blendin:
  • the amount of blending between this animation and the previous one on this layer.
  • Type:  float number
mode:
  • the play mode.
  • Type:  KX_ACTION_MODE_PLAY, KX_ACTION_MODE_LOOP, or KX_ACTION_MODE_PING_PONG
layerWeight:
  •  how much of the previous layer to use for blending (0 = add)
  • Type: float
ipoFlags:
  • flags for the old IPO behaviors (force, etc)
  • Type: int bitfield
speed:
  • the playback speed of the action.
  • 1.0 = normal playback speed, 2.0 = twice normal speed, and so on
  • Type:  float number
Sample Code

################## play an action
 
# import bge
import bge

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

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

# set action variables
name = "WalkCycle"
start = 1.0
end = 20.0
layer = 3
priority = 1
blendin = 1.0
mode = KX_ACTION_MODE_LOOP
layerWeight = 0.0
ipoFlags = 1
speed = 1.0

# play an action
obj.playAction(name, start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)