I'm having a problem that animations doesn't apply the mixduration when setting them in Unity.
It just pops in position with SetAnimation, but when doing SetEmptyAnimation it mixes.
However, if I toggle the animation during the time that the other animation plays, it smoothly mixes back and forth.
Why is that? See images below. Please ignore the hickup in spine, it's due to the aim ik bone being in the wrong place. 🙂
The on screen debug is hidden if the animation is null, so it seems that when setting an animation from a track where skeletonAnimation.state.GetCurrent(trackID) is null, it doesn't blend.
Does Spine do it differently? And can I fix it?
Here's the code:
// I provide these values "int track, Spine.Animation anim, float mixDuration"
if (anim != null) {
baseTrack = skeletonAnimation.state.SetAnimation(track, anim, loop);
Debug.Log($"SetAnimation {anim} on track {track} in {mixDuration} seconds");
baseTrack.MixDuration = mixDuration;
return;
} else {
if (skeletonAnimation.state.GetCurrent(track) == null ||
skeletonAnimation.state.GetCurrent(track).Animation == null) {
Debug.Log($"Track {track} is already empty");
return; // Don't set empty if already is
}
baseTrack = skeletonAnimation.state.SetEmptyAnimation(track, mixDuration);
Debug.Log($"SetEmptyAnimation on track {track} in {mixDuration} seconds");
return;
}