Hi all,
I'm having an issue with events that I hope you can help me solve.
I have a set of 8 RUN animations for a character, one for each direction. All animations are 0.8s long and have two custom events so I can play step sounds. Events are set in 0s and 0.4s.
In order to keep animation transitions smooth when the player moves around I set the TrackTime like this:
float startTime = 0;
if (animationIsPlaying)
{
startTime = controller.CharacterAnimation.AnimationState.GetCurrent(0).AnimationTime;
}
TrackEntry trackEntry = controller.CharacterAnimation.AnimationState.SetAnimation(0, newAnimationName, true);
trackEntry.TrackTime = startTime;
So, I was expecting this:
0.0s: Player starts moving with direction E (for example). First step event is fired.
0.3s: Player changes direction to SE (or any other different direction). No event is fired.
0.4s: Player keeps moving with direction SE. Second step event is fired
0.7s: Player changes direction to E (or any other different direction). No event is fired.
0.8s: Player keeps moving with direction E. First step event is fired (loop).
...
But instead, I get this:
0.0s: Player starts moving with direction E (for example). First step event is fired.
0.3s: Player changes direction to SE (or any other different direction). First step event is fired (again!).
0.4s: Player keeps moving with direction SE. Second step event is fired.
0.7s: Player changes direction to E (or any other different direction). First AND second events are fired (again!)
0.8s: Player keeps moving with direction E. First step event is fired (loop).
...
While looking for the cause of this issue, I tried forcing the startTime to 0.7s (for example), so any RUN animation would always start at 0.7s. The result is that both step events are fired at 0.7s, although the Spine.Event.Time values are 0 and 0.4.
So, it seems that it doesn't matter what start time I set the animation to begin at; all previous events in the animation will be fired instantly when the animation starts playing.
Am I doing anything wrong? How can I ignore past events while using TrackTime to start an animation at a specific time?
Thanks!
Javi