First off, I know it’s a bad idea to use the bpy in the game engine; just bear with me for a second.
This piece I wrote works perfectly inside Blender,
import bge, bpy
class DS_Anim:
layer = 0
priority = 0
mode = 0
layerWeight = 0
ipoFlags = 0
isLoop = False
isTransition = False
def __init__(self, name, speed):
self.name = name
self.speed = speed
self.start = bpy.data.actions[name].frame_range[0]
self.end = bpy.data.actions[name].frame_range[1]
if self.isCycle:
self.end -= 1
def getCurrent(self, obj):
self.currentFrame = obj.getActionFrame(self.layer)
def play(self, obj):
self.getCurrentFrame(obj)
obj.playAction(self.name, self.start, self.end, self.layer,
self.priority, self.blend, self.mode,
self.layerWeight, self.ipoFlags, self.speed)
def playback(self, obj):
self.getCurrent(target)
target.playAction(self.name, self.end, self.start, self.layer,
self.priority, self.blend, self.mode,
self.layerWeight, self.ipoFlags, self.speed)
def stop(self, target):
target.stopAction(self.layer)
Then there’s a few more class functions and bunch of subclasses where I define different kinds of animations (idles, movement, etc) and assign them to their corresponding layer, mode and priority values, but you get the main idea: it’s a simple module that helps organizing the process of playing actions… and it’s very, VERY nice to just let blender use it’s knowledge of the action in question instead of typing beggining and end frame for each animation like a lunatic, because if I want the action to stop or start at a specific point I just have to call a function.
And here comes the question: how exactly should I go about “fixing” this system so that it doesn’t depend on the bpy? I’ve been googling this stuff and no one seems to even be using a similar method so, any ideas?