Hey @Nate , I'm trying to follow these steps https://es.esotericsoftware.com/forum/d/18360-animation-mixingblending/3 in order to blend 2 animations: "idle" on track 0 and "stunned" on track 1, working with a SkeletonAnimation; however, my character is literally blowing up when the secondary track animation is played (by blowing up I mean their limbs are detached from their body).

As I'm not sure if I'm missing something, I'll explain my workflow; both animations have the same duration and my code is something like this

_skeletonAnimation.Skeleton.SetToSetupPose();
track1 = _skeletonAnimation.AnimationState.SetAnimation(0, "idle", true);
track1.MixBlend = MixBlend.Add; //it shouldn't be necessary since it's in the track 0
track1.Alpha = 0.5f;
track2 = _skeletonAnimation.AnimationState.SetAnimation(1, "stunned", true);
track2.MixBlend = MixBlend.Add;
track2.Alpha = 0.5f;

I'm a bit lost, any help would be really helpful, thanks in advance!

Related Discussions
...

@jfez You seem to have misunderstood MixBlend.Add. See the documentation here:
http://esotericsoftware.com/spine-api-reference#MixBlend-add
This means that you don't want to set it on track index 0, and when setting it on a higher track you need to ensure that lower track animations already key the same attributes (like e.g. rotation), otherwise your values will be ever-increasing each frame.

  • jfez がこの投稿に返信しました。

    Harald oh... I see! It seems it isn't what I was looking for, apologies!

    Could you give me a piece of advice to solve my problem mixing 2 animations on different tracks? For the good of the project, it's mandatory that base anim, "idle" in this case, is on the track index 0, it's that possible? Thanks!

    Try:

    _skeletonAnimation.Skeleton.SetToSetupPose();
    _skeletonAnimation.AnimationState.SetAnimation(0, "idle", true);
    TrackEntry track2 = _skeletonAnimation.AnimationState.SetAnimation(1, "stunned", true);
    track2.Alpha = 0.5f;
    • jfez がこの投稿に返信しました。

      Nate yeah, that's what I tried in the first place, however, I wasn't happy with the result since I was getting a clunky transition between the previous animation (let's call it "shaking") and the mixed "idle" + "stunned" animations. Looking for possible ways to fix the problem, I found the MixBlend but it didn't work as I thought.

      Researching again, I've read this thread https://es.esotericsoftware.com/forum/d/16533-no-mix-at-a-higher-track-sometimes/6 and it seems to be the final answer to my issue! So just in case somebody needs it, here's my code to blend 2 animations on different tracks smoothly:

       _skeletonAnimation.Skeleton.SetToSetupPose();
      _skeletonAnimation.AnimationState.SetAnimation(0, "idle", true);
      _skeletonAnimation.AnimationState.SetEmptyAnimation(1, 0.2f);
      TrackEntry track2 = _skeletonAnimation.AnimationState.AddAnimation(1, "stunned", true, 0f);
      track2.Alpha = 0.5f;

      Thanks all of you for your help! @Nate @Harald

      SetEmptyAnimation(1, 0.2f); the second parameter is a mix duration. If you are not already playing anything on track 1, you aren't mixing from anything so you can pass 0.

      On track 1 your code will mix from the empty animation to the stunned animation using the default mix time (from AnimationStateData). This means that instead of stunned being applied fully right away, it is applied from nothing to fully over the mix duration.

      Due to alpha 0.5, the stunned animation will be applied such that you get a pose halfway between the pose from idle and stunned.

      • jfez が「いいね」しました。