From BlenderWiki
BGE Animation Proposal
Python API
The following method will be added to KX_GameObject:
playAction(name, start, end, layer=0, priority=0, blendin=0, play_mode=KX_ACTION_PLAY, blend_mode=KX_ACTION_ADD):
- name -- the name of the action
- start -- the start frame of the action
- end -- the end frame of the action
- layer -- the layer the action will play in (actions in different layers are added together)
- priority -- only play this action if there isn't an action currently playing in this layer with a lower priority
- blendin -- the amount of blending between this animation and the previous one on this channel
- play_mode -- the play mode (KX_ACTION_PLAY, KX_ACTION_LOOP)
- blend_mode -- how the animation layers are to be blended together (KX_ACTION_ADD, KX_ACTION_BLEND, KX_ACTION_REPLACE)
Logic Brick
A new logic brick will be created (“Action” would be a good name, but it’s already taken). The options for the actuator will mimic the parameters from the playAction() method.
Implementation
The playAction() method will be added to KX_GameObject and borrow code from the Fcurve, Shape Action, and Action actuators as needed. Currently running actions will be added to a list on the KX_GameObject and will be updated every frame. The list will probably be an array of some arbitrary length, which will also act as the maximum number of layers. As such, each element in the array is an animation layer. Running actions will be stored in the actions array as a BL_Action object, which will keep track of things like frames and possibly deal with blendin. If there is no action running on the layer, it will be NULL, or some sort of empty BL_Action.
Things to think about
- Dynamic options of the fcurve actuator
- How to implement play modes that rely on negative pulses as flipper, loop stop, loop end, etc.
- Continuous mode