As far as I understand, as long as EventThreshold is set to its default value (0), no events should be fired by an animation if it is interrupted, right? But I'm receiving them.
Not exactly. EventThreshold:
When the mix percentage (getMixTime() / getMixDuration()) is less than the eventThreshold, event timelines are applied while this animation is being mixed out. Defaults to 0, so event timelines are not applied while this animation is being mixed out.
It's not about being interrupted. It's about whether event timelines are applied while the track entry is mixing out.
If I understand your sequence:
attack1
at 0.23 eShoot event fires (for attack1)
at 0.25 attack1 is interrupted by attack2 playing
at 0.23 eShoot event fires (for attack2)
at 0.25 attack2 is interrupted by attack3 playing
at 0.23 eShoot event fires (for attack3)
By the time you interrupt an attack, the eShoot
event was already fired.
BTW, if your animation is not looping, you probably don't need to remove the callbacks on a TrackEntry. You would if you were using callbacks on the AnimationState, but callbacks on TrackEntry are usually better because you don't need to do such clean up.
As Spinebot mentioned, the complete
event occurs even if the track entry is mixing out. The fix is likely to skip complete
events that are not for the current track entry. Or I suppose you could remove the callback in interrupted
, but I usually prefer not to juggle callbacks if there is a simpler solution.
You didn't specify mix durations for your sequence. You interrupt at 0.25 and your animation duration is 0.4, so you'll see a complete event if your mix duration is 0.4 - 0.25 = 0.15
or higher.
It's not clear why you don't receive the second complete
event. The callbacks are per track entry, removing a callback doesn't affect other track entries.
One possibility is the game does a few large time advances from one frame to the next. That would shorten the 0.15 seconds (150ms) needed to see the complete
event. Eg, the game updates to animation time 0.24, the next update is at 0.32 and (assuming your code sets the next attack animation rather than addAnimation
) the next attack interrupts (a bit later than the ideal 0.25), then the next update is 0.4 and complete fires. 80ms jumps would be pretty noticeable though.
Make sure you don't store a track entry reference and use it after the end
event. If you only use the track entry in the callback, it's safe.
To debug further, write standalone code that sets animations and advances the animation state time so you can understand the behavior without the rest of the game.