auer_spine

Question about Spine:
--------------------------------------
The following issue occurs when we upgrade Spine 2.1 to 3.8 at Unity 2018.3.5f1
Sample code:
SkeletonAnimation anim;
anim.state.SetAnimation(0, "Idle", true);
anim.state.SetAnimation(1, "Attack", false);

Circumstances under Spine 2.1
Play Idle ---> Attack ---> Idle
Loop normally
(Attachment: Spine2.3_2.gif)
Spine2.3_2.gif



Circumstances under Spine3.8
Play Idle ---> Attack ---> Nothing happens
Seems that track 1 still running might be the cause
(Attachment: Spine3.8_2.gif)
Spine3.8_2.gif


Does anyone know what could be causing this?
You do not have the required permissions to view the files attached to this post.
auer_spine
  • Posts: 2

Harald

Could you please try adding the following line to your code, to enqueue the empty animation after the attack animation:
anim.state.AddEmptyAnimation(1, 0.0f, 0.0f); // mixDuration and delay both set to 0.0
This should mix out your animation on track 1.
User avatar
Harald

Harri
  • Posts: 1500

auer_spine

var anim = GetComponent<SkeletonAnimation>();
anim.state.End += trackEntry => {
if (trackEntry.TrackIndex == 1)
{
// do something...
}
};

anim.state.SetAnimation(0, "Idle", true);
anim.state.SetAnimation(1, "Attack", false);
anim.state.AddEmptyAnimation(1, 0.0f, 0.0f);

After we adjusted the code as the method above, the animation works.
Play Idle ---> Attack ---> Idle

-----------------------------------------------
However, "AddEmptyAnimation()" will sent "End event" when the animation is done playing
Which leads to the "do something..." logic to execute again.

Will this problem be fixed, or it will be adjusted to add into "AddEmptyAnimation()" ?
auer_spine
  • Posts: 2

Harald

auer_spine wrote:Will this problem be fixed, or it will be adjusted to add into "AddEmptyAnimation()" ?
Sending the End event is by design, please see the API reference page here:
AnimationStateListener
So I fear that you will need to adapt your code accordingly. Note that you can query trackEntry.Animation to react differently according to the animation that just ended.
User avatar
Harald

Harri
  • Posts: 1500


Return to Unity