maasha

:hi: Hi there,

There are several mouth animations in my game, and the mouth changes depending on the animation/emotion. That means if the mouth is not the same mouth layer as the default mouth, there will be a snap when the mouth animation loop ends.

For example let's say my default mouth is A. And I have a B emotion with a B talking mouth animation playing.
What happens when B mouth animations stops is it snaps the mouth back to A mouth.

I did notice though when I don't loop the mouth animation, when the animation ends, at least within the Spine Editor, the animation stays on the last frame without snapping. It only snaps again if I remove that animation from the Track.

In Unity though, it's designed to snap back to default after the loop ends, correct? Since this is a mouth animation though, it needs to loop, so I'm stuck with this issue.

One way I thought to get around this is when the last loop ends, keep the animation on the last frame, like in the Spine editor, so it doesn't snap to default. The snap can then happen behind the scenes when I change emotion while the camera is focused on another character.

So in summary, how can I set the B mouth animations to the last frame when the last loop ends?
I already have the Complete event, is there some way I can just set it to freeze for this particular animation? Of course the other animations like blinking and breathing etc that are running on different tracks should still work.
SkeletonGraphic.AnimationState.Complete += delegate (Spine.TrackEntry TrackEntry) {
// set the animation to freeze at last frame and not reset to default layers
};
Thank you for your help.

---
UPDATE:
I just set timescale to 0 for that track entry inside that event and I tested a few more things it looks good. Just wanted to ask if there are any potential hiccups that might come up from this, that I may not be aware of yet? Thanks so much!
maasha
  • Posts: 18

Harald

How exactly did you set the animations at the tracks?

I just did a quick test with Spineboy and the mouth shape was retained active at the end of the non-looping second track:
skeletonAnimation.AnimationState.SetAnimation(0, "walk", true);
skeletonAnimation.AnimationState.SetAnimation(1, "death", false);
After the end of the death animation, the mouth stayed at death's last frame's "mouth-ooo" attachment.
User avatar
Harald

Harri
  • Posts: 2410

maasha

Yes that's for non-looping. What if we wanted to loop and then stop at the last frame after a certain amount of loops?
Like this is really important for talking animations. It would have been great to have this flexibility.
maasha
  • Posts: 18

Harald

I think I misunderstood your question the first time.

That sounds as if you are missing a keyframe at the start of your animation, if entering the next loop causes a "snap" to happen.

There is also no snapping happening with Spineboy when changing loop to true:
skeletonAnimation.AnimationState.SetAnimation(0, "walk", true);
skeletonAnimation.AnimationState.SetAnimation(1, "death", true);
User avatar
Harald

Harri
  • Posts: 2410


Return to Unity