Game Development Community

End of animation callbacks

by Matt Huston · in Torque 3D Professional · 05/15/2011 (2:38 pm) · 3 replies

I am looking at implementing a script callback when non-cyclic animations have been completed. Does anyone have a good place in the code to implement this? I haven't found one - I noticed there is a value called in the Player class, ActionAnimation struct called atEnd and have placed some breakpoints and do not hit them when the animation is complete.

#1
05/16/2011 (12:46 am)
Just implemented script-based ::onEndSequence() method and engine will automatically call it at the end:

/// Called when a thread playing a non-cyclic sequence reaches the end of the sequence
function MyDataBlock::onEndSequence(%data, %obj, %slot)
{
   // %data -- datablock of ShapeBase-derived object (player incl.)
   // %obj -- the object, animation is played on
   // %slot -- thread slot that finished playing
   // Do the stuff here
}
#2
05/16/2011 (2:16 am)
Because I haven't find any way to make use of playThread() without it breaking the player's animations, I wanted to add that there's also a PlayerData::animationDone(%this, %obj) callback that is triggered at the end of a sequence initiated by setActionThread(), which works fine for me.
#3
05/16/2011 (3:35 am)
Thank bank and Lunacy, using Player object so the animationDone is the callback, I see if the object is ShapeBase I'd use the onEndSequence. Appreciate the heads up, I completely missed those callbacks.