Hi Xaby, thanks for the suggestions. Do you know if the animation names are only loaded with certain file formats? I use FBX and the animations are always stored in a list by name. I suppose I could chain them all together into one big animation in blender and then just go by the animation time, but I like the idea of them being stored separately.
Anyway, I did end up using a couple of type definitions. Here is a simplified version of my animation event code if anyone's interested.
type AnimatedObject
objectID as integer
currentAnim as string
previousTime as float
currentTime as float
endtype
type AnimatedObjectEvent
animName as string
eventTime as float
endtype
function LoadAnimatedObject(file$)
obj as AnimatedObject
obj.objectID = LoadObjectWithChildren(file$)
endfunction obj
function PlayAnimatedObject(animObj ref as AnimatedObject,anim$,start#,end#,loopFlag,tween#)
animObj.currentAnim = anim$
PlayObjectAnimation(animObj.objectID,anim$,start#,end#,loopFlag,tween#)
endfunction
function UpdateAnimatedObject(animObj ref as AnimatedObject)
animObj.previousTime = animObj.currentTime
animObj.currentTime = GetObjectAnimationTime(animObj.objectID)
endfunction
function NewAnimatedObjectEvent(animObj ref as AnimatedObject,animName$,eventTime#)
event as AnimatedObjectEvent
event.animName = animName$
event.eventTime = eventTime#
endfunction event
function GetAnimatedObjectEvent(animObj ref as AnimatedObject, event ref as AnimatedObjectEvent)
if GetObjectIsAnimating(animObj.objectID)
if animObj.currentAnim = event.animName
if animObj.previousTime = event.eventTime
exitfunction 1
endif
if animObj.previousTime < event.eventTime and animObj.currentTime > event.eventTime
exitfunction 1
endif
if animObj.previousTime > animObj.currentTime and animObj.previousTime < event.eventTime
exitfunction 1
endif
endif
endif
endfunction 0
and to use it:
Obj as AnimatedObject : Obj = LoadAnimatedObject("filename")
Event as AnimatedObjectEvent : Event = NewAnimatedObjectEvent(Obj,"animation name",eventTime#)
PlayAnimatedObject(Obj,"animation name",startTime#,endTime#,loopFlag,tween#)
do
UpdateAnimatedObject(Obj)
if GetAnimatedObjectEvent(Obj,Event)
// do stuff, such as playing a sound in sync with animation
endif
sync()
loop
-h