• Unity
  • Spine 4 - change in behavior with EmptyAnimation

  • تم التحرير
Related Discussions
...

Hello Harald and everyone :grinteeth:

Just updated to Spine 4 and am working out any kinks.

There is a behavior change when I apply an empty animation to a track that is already empty, and then immediately use AddAnimation().

skeletonAnimation.AnimationState.AddEmptyAnimation(0, 0, 0);

TrackEntry newTrack = skeletonAnimation.AnimationState.AddAnimation(0, "myAnim", false, 0);
newTrack.MixDuration = 0.1f;

Expected behavior (before Spine 4 update): The "myAnim" animation would mix in immediately with 0.1f mix duration.

New behavior with Spine 4: The "<Empty>" empty animation lasts for about a second long, and THEN it plays myAnim. In case it matters, the "myAnim" animation is 35 frames long.

Is this intended or possibly a bug? If I need to make a repro / post a bug report I can, but thought it possibly could be an intentional change? Also just to make sure its clear, it only happens when the track is empty (so would have to clear the track each time when testing).

Also I realize there isn't really any reason to first add an Empty Animation to a track that is already empty, and then to immediately use AddAnimation (I could just skip the Empty Animation part), but I figured I'd ask about it since it seems a bit strange.

Thanks for the help!

Good question! :nerd:
It can be resolved by setting the delay of the empty animation:

TrackEntry empty = skeletonAnimation.AnimationState.AddEmptyAnimation(0, 0, 0);
empty.Delay = 0;

This line is responsible for it, admittedly I don't remember whether there was a design decision for it not to assign 0 here. We will get back to you with additional info 🙂.

Harald wrote

Good question! :nerd:
It can be resolved by setting the delay of the empty animation:

TrackEntry empty = skeletonAnimation.AnimationState.AddEmptyAnimation(0, 0, 0);
empty.Delay = 0;

This line is responsible for it, admittedly I don't remember whether there was a design decision for it not to assign 0 here. We will get back to you with additional info 🙂.

Hey Harald! Thanks for the info!

Just to add more info, I tried doing this:

TrackEntry emptyEntry = skeletonAnimation.AnimationState.AddEmptyAnimation(0, 0, 0);
emptyEntry.Delay = 0f;

TrackEntry newTrack = skeletonAnimation.AnimationState.AddAnimation(0, "myAnim", false, 0);
newTrack.MixDuration = 0.1f;

This did fix that particular issue (the myAnim started playing immediately) when the track is empty, but now if I trigger that code multiple times without clearing the track the myAnim starts to play for a moment (maybe like 0.1 seconds) and then stops :think:


(That being said, I don't really see a use-case for if you have an animation currently playing on a track, to then use AddEmptyAnimation and then AddAnimation like how I am testing it... lol)

The original issue has just been fixed, a new 4.0 spine-unity unitypackage is available for download here as usual:
Spine Unity Download
Please have a try if it resolves your other issue as well!

Harald wrote

The original issue has just been fixed, a new 4.0 spine-unity unitypackage is available for download here as usual:
Spine Unity Download
Please have a try if it resolves your other issue as well!

Thanks Harald, looks to have fixed both issues! :yes: :yes:

Awesome! It wasn't me who fixed it but Nate, I hereby redirect all praise to him! 🙂