marmotje

Hi,

I'm currently prototyping controls for a 2D game, and our animator put together a quick character with basic animations to test things out. Most of them all work fine, but there's this one issue where blending between being crouched and crawling does a weird effect where it seems to be blending to something totally unrelated. Both animations loop perfectly by themselves, and blend perfectly to other animations, but between them (both ways), it has this weirdness. See the video below. I've attached a stripped down spine json file with the two animations having the issue, if that would be helpful. I don't have much experience hooking up spine animations in Unity, but it seems to be fine for all the other transitions I made.
Hopefully someone can point me in the right direction with this.

Thanks.

Attachments
Zephyr.json
Stripped down exported json
(23.21 KiB) Downloaded 43 times
marmotje
Posts: 6

Nate

Do you have the latest spine-unity runtime?
User avatar
Nate

Nate
Posts: 8284

Xelnath

This looks like the dipping problem from an old spine runtime.
Xelnath
Posts: 407

marmotje

It should be the latest official version. I've downloaded it from http://esotericsoftware.com/spine-unity-download/ past Friday, the 3.6 May 25 version.
At first I thought maybe it was an upgrade issue, cause I was using an older unity project which had an older version, but I replicated this on a blank project in which I only imported the latest version. Possible the bug has been introduced again in a recent version? I can try a few older versions tonight to see if that would change anything, do you happen to know (more or less) when this issue was fixed before?
marmotje
Posts: 6

Pharan

I've imported the json you shared into a spine-unity for Spine 3.6 project, and tried switching back and forth between crawl_idle_new and crawl_new.
There doesn't seem to be a problem with the animation. It doesn't look like your video.

https://streamable.com/0a7o9

Is there something more to your code that might not have been mentioned?
User avatar
Pharan

Pharan
Posts: 5220

marmotje

The project was completely blank, only using the generated animator to automatically blend animations. It looks fine if I switch them back to back, but if I crossfade them, it had that little bump up.
I'll give it another try tonight, create a new blank project and redownload the package. If I still get the same issue, I'll upload that test unity project as a whole.

---

I've tried it again, double checking and redownloading the latest spine runtime, and it's still happening.
I've attached the Unity project containing the animation, the spine runtime, and a scene having the character setup to animate. Maybe I'm overlooking something really basic here, but I can not figure it out. And as I said, if I use the other animations, they all do behave as expected.

Thanks for your time and help with this, much appreciated.
Attachments
SpineAnimTest.rar
unity project
(713.93 KiB) Downloaded 45 times
marmotje
Posts: 6

Pharan

Oh, you were using SkeletonAnimator.
That does have some mixing limitations because of the limitations of what the Unity Mecanim API makes available.
We haven't been able to check if the newer version of Unity can allow us to overcome this but this won't be fixed in spine-unity for Spine 3.6.
Maybe 3.7 if it's possible at all. (note:SkeletonAnimator will be called SkeletonMecanim in 3.7)

The workaround is to disable "auto reset" in the SkeletonAnimator's inspector. And then make sure your animations have matching keyed skeleton properties. (eg, if the torso's rotation is keyed in animation A, it should also be keyed in B).

SkeletonAnimation does not have this problem, as shown in the linked video above.
User avatar
Pharan

Pharan
Posts: 5220

marmotje

Ah, I wasn't aware of that. We are using Corgi engine for Unity as a base, which has instructions to use the SkeletonAnimator to integrate with their character controls which set mecanim properties to control the animations. I'm reworking some controls and expanding them, so I can convert it to use SkeletonAnimation instead.

About this workaround you mentioned, does it mean that every single animation that could be mixed, requires to have keyframes on the same times? Or just in general have a keyframe? All our animations should have keyframes on all bones at start and end of every animation, so if that would suffice, trying to disable auto reset might be a quick solution. Does this have any other known impact that I should be cautious of?

Thanks!
marmotje
Posts: 6

Pharan

Now that I think about it, this workaround is probably much easier to preprocess all the animations in SkeletonData at loadtime to do this for you in Unity code. This way, it doesn't require you to muddy up your Spine project dopesheet. I'll try this code out and get back to you about it tomorrow.

If you are using animations in a multi-layer way though, it may require you to do things manually, or modify the code to pick the correct animations.
If you're curious about your questions though. Yes, just having keys at the start of the animation is enough. The point is that the keyed properties need to match among all animations that might be mixed. Not the key times. DO NOT add keys to every skeleton/bone property naively, as this will adversely affect performance.
User avatar
Pharan

Pharan
Posts: 5220

marmotje

Nice, that might be useful. We gave a try by disabling the auto reset, and it worked well. All the other animations are still blending properly too, so this seem to do the trick nicely.
If you find out more about that preprocessing technique, I'm all ears. At the very least it is useful to learn more about it for me and others.

Thanks again for your help, I really appreciate tools that have such active support, and help you get to a workable solution :)
marmotje
Posts: 6

Pharan

It's not quite ready yet but the gist of this would be that you would only need to call this once at load time.
var skeletonData = skeletonDataAsset.GetSkeletonData(true);
AnimationTools.MatchAnimationTimelines(skeletonData.Animations, skeletonData);
Then the code will process the given animations so their timelines correctly match for SkeletonAnimator mixing.
For special layered animations where different sets of animations need to match, you'd call MatchAnimationTimelines for each subset, and pass that subset as the first arg.

The current state of AnimationTools lives here for now: https://gist.github.com/pharan/c9793f0bb35345f537e515cc0d653f58
It hasn't been included in the official runtime yet so the sample code above will not work until you include AnimationTools.cs into your project.
User avatar
Pharan

Pharan
Posts: 5220

marmotje

Sorry for the late reply, I was out for a few days. Thanks for your efforts! I shall give it a try later this week.
marmotje
Posts: 6


Return to Unity