nicmar

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;
}


We're making SpaceChef with Spine. An action filled cooking adventure. We're coming soon to Kickstarter, sign up for our newsletter to be the first to get notified: www.spacechefgame.com. Follow our work on Twitter @BlueGooGames.
Avatar de l’utilisateur
nicmar
  • Messages: 137

Harald

From the documentation here:
Mixing in is done by first setting an empty animation, then adding an animation using addAnimation with the desired delay (an empty animation has a duration of 0) and on the returned track entry, set the mixDuration.
So to always mix-in even when there is nothing playing on the track, you need to call SetEmptyAnimation() followed by AddAnimation(aim).

Please see the documentation for additional details:
AnimationState setEmptyAnimation
AnimationState setAnimation2
Avatar de l’utilisateur
Harald

Harri
  • Messages: 3996

nicmar

Thanks a lot, i missed that part of the docs. It worked like a charm! :)
We're making SpaceChef with Spine. An action filled cooking adventure. We're coming soon to Kickstarter, sign up for our newsletter to be the first to get notified: www.spacechefgame.com. Follow our work on Twitter @BlueGooGames.
Avatar de l’utilisateur
nicmar
  • Messages: 137

Harald

No problem, glad to hear it's working as expected now! :)
Avatar de l’utilisateur
Harald

Harri
  • Messages: 3996


Revenir vers Runtimes