Hi, I encountered the problem of character animations changing instantly when playing Spine animations on different tracks using Unity.
I am continuously looping the idle animation on track 0, and when I click on my character, I will play the select animation on track 1.
My character holds a shield in their right hand and hangs it next to their right foot. In idle animation, the shield floats up and down with character's breath, but in select animation it stays down. So when the shield floats above, clicking on the character will immediately cause the shield to appear below. What I expect is that when I click, the shield will still stays in its original position and slowly blend to the position where the two animations have been mixed. Simply put, it means changing more smoothly.
Is this possible?
Here is my code (nothing special):
public void Start()
{
_skeleton.AnimationState.SetAnimation(0, idleAnimationName, true);
}
public void SetSelect()
{
_skeleton.AnimationState.SetAnimation(1, selectAnimationName, false);
}
I know I can modify the blending result by setting TrackEntry.Alpha
, but I think it only changes the degree how the select animation is blended into the idle animation, and cannot modify the smoothness when Track 1 starts playing the animation. The position of the shield will still change instantly in the first frame, just changes from 100% (alpha=1) down to 50% (alpha=0.5) down or less.
I have consulted the API's instructions on parameters such as mixBlend
and mixDuration
, and my understanding is that they only affect the blending effect when different animations are played on the same track, and do not affect the blending of animations on different tracks.
I checked the spine json file exported by my animation friend. In fact, the bones' positions of the shield were both modified in two animations. So I deleted position modifications in select animation and only kept the scale-changing part. After that, when I selected the character, the shield did not instantly switch positions and the animations changed smoothly. Is this the only way ?