iron59

I'm trying to pause the animation of a SkeletonAnimation object at a particular frame. What I did first was to set the animation using the following code:
this.spineAnim.state.SetAnimation(0, animName, loop).TimeScale = speed;
After this I pause the animation by setting the TimeScale property of the SkeletonAnimation to 0. And then I set the time of the track entry using the following code.
Spine.TrackEntry trackEntry = this.spineAnim.state.GetCurrent(0);

// QQQ
Debug.LogWarning(this.itemCode + " Seek Time: " + seekTime.ToString());
Debug.LogWarning("Before - " + trackEntry.Animation.Name + " Duration: " + trackEntry.Animation.Duration.ToString() + " Time: " + trackEntry.AnimationTime);

trackEntry.TrackTime = seekTime;

// QQQ
Debug.LogWarning("After - " + trackEntry.Animation.Name + " Duration: " + trackEntry.Animation.Duration.ToString() + " Time: " + trackEntry.AnimationTime);
However, the pose of the spine animation did not change. When I traced the spine animation I get this:
arm4 Seek Time: 2
Before - idle Duration: 2 Time: 0
After - idle Duration: 2 Time: 0
Any suggestions on how to fix this? Thank you very much.
iron59
Posts: 16

Pharan

Are you sure TrackEntry has already finished mixing in?
Here's the code that determines the deltaTime that is used for the mixing to proceed: spine-runtimes/AnimationState.cs at 3.6
If you set the TimeScale of the SkeletonAnimation to 0, mixing will not progress.
If you set the TimeScale of the previous TrackEntry to 0, mixing will not progress.

If mixing (MixTime) is stuck at 0, that TrackEntry's pose will be applied with a 0 alpha. (the pose will not be visible)
The TrackEntry's pose will be fully applied once the mix is complete.

If this is actually the problem, you may need to add:
trackEntry.MixTime = trackEntry.MixDuration;
Or make sure you have a 0 mix duration.
Or you can also add deltaTime to trackEntry.MixTime per update to still make it animate.

If not, the problem may be something else.
User avatar
Pharan

Pharan
Posts: 4942

iron59

Yup. Setting the MixTime solved it. Thank you so much for the help. :)
iron59
Posts: 16


Return to Unity