• Unity
  • Skeleton Mecanim Layer Mix Modes & Layer Blend Modes

Related Discussions
...

Been using Spine for years with Libgdx and am now taking a look at Skeleton Mecanim in Unity.

Is there an in-depth explanation of what the different Layer Mix Modes and Layer Blend Modes do?

From http://esotericsoftware.com/spine-unity:

Layer Mix Modes. This parameter determines the animation mix mode at each layer. You can change it from SpineStyle to Always Mix or Mix Next to get behaviour more related to usual Mecanim transitions, respecting Mecanim transition weights. When set to SpineStyle it will be more consistent with Spine Editor preview or SkeletonAnimation behaviour, and it will ignore Mecanim transition weights.

When I set my Skeleton Mecanim to use "Spine Style" there is no mixing between any animations - they all snap to the next animation. What should I be doing here? Is there a place I should be setting the default mix time and specific mix times?

I googled around to try to figure out what "always mix" and "mix next" would mean in regards to Unity's Mecanim but didn't find anything. I was having some success with using "mix next", which indeed looked to be using unity's 'transition' timings, but then ran into some issues when I added an additional Layer to my Animator Controller, so I figured I'd come here and ask instead of fumbling around.

"Layer Blend Modes" isn't mentioned in the Spine-Unity documentation. I'm assuming its how each additional layer blends with the previous ones (replace, additive), and that the 'first' layer should be set to First. What does Setup do? How do these settings interact with Unity's Animator Layer settings (the Weight slider, and the Blending drop-down menu)?

Testing out the Spine Mecanim has been really fun, I just need to clear up these couple things - thanks for any help! :grinteeth:

Edit: Might as well also ask a question about the issue I was running into.

My spine character needs two Layers - a 'main' layer that animates the fully body when running, and only the legs when attacking. And then an 'arms' layer that animates the arms only when attacking.

When the character starts attacking, the arms snap into place, and when the character finishes attacking, the arms snap 'back' from the completed arm movement animation. Using Libgdx, I believe I had fixed this issue by adding Empty Animations before and after the arm movement animations on the 'arms' layer.


Mini update to the issue I was having (arms snapping) - I created an empty animation in Spine, and set the before/after States to use that empty animation on the arms-layer and it looks to be working! Should've tried that sooner 😃

We are sorry for the confusion!

I have improved the documentation text at the spine-unity documentation pages:
spine-unity Runtime Documentation: SkeletonMecanim Component

Spine Style has been renamed to Hard to make it more intuitive (it was misleading before). Additionally, the new default value for new SkeletonMecanim components is now MixNext instead of SpineStyle/ Hard, as this is what most users will want to use. Updated unitypackages are available for download here as usual:
Spine Unity Download

Please let me know if it is more clear now.

Jamez0r escreveu

I googled around to try to figure out what "always mix" and "mix next" would mean in regards to Unity's Mecanim but didn't find anything.

These are Spine terms, not Unity Mecanim terms.

Jamez0r escreveu

I was having some success with using "mix next", which indeed looked to be using unity's 'transition' timings, but then ran into some issues when I added an additional Layer to my Animator Controller, so I figured I'd come here and ask instead of fumbling around.

Could you please tell us what issue you have been running into?

"Layer Blend Modes" isn't mentioned in the Spine-Unity documentation. I'm assuming its how each additional layer blends with the previous ones (replace, additive), and that the 'first' layer should be set to First. What does Setup do? How do these settings interact with Unity's Animator Layer settings (the Weight slider, and the Blending drop-down menu)?

You cannot edit the Layer Blend Mode directly, it will automatically be synced with each Mecanim layer's Blending parameter in the Animator panel. Anyway, I have added a section to the updated spine-unity docs page as well:
spine-unity Runtime Documentation: SkeletonMecanim Component
I think I will remove the Layer Blend Mode parameters from the inspector, as it is autimatically set and may now only lead to confusion.

Since you have already been using libgdx, you might want to use SkeletonAnimation instead of SkeletonMecanim to be able to reuse your existing code (with only slight adaptations). Was there a reason why you chose to use SkeletonMecanim instead?

Hey Harald! Thanks a lot for the info/updates!

Could you please tell us what issue you have been running into?

I edited my original post to add the issue as well as the solution I came up with (adding a literal 'empty animation' to the before/after states in my "arms" layer to prevent them from snapping).


Since you have already been using libgdx, you might want to use SkeletonAnimation instead of SkeletonMecanim to be able to reuse your existing code (with only slight adaptations). Was there a reason why you chose to use SkeletonMecanim instead?

I'm researching how I'd go about setting up a multiplayer game in Unity, using Spine and PUN2. I've been talking to a guy who made an asset called "Simple Sync Animator" that synchronizes Unity "Animators" over the network and is compatible with PUN2. So I configured my characters with Spine Mecanim and, lo and behold, they look GREAT over the network. I've really been enjoying testing out the SkeletonMecanim, so thanks for that!

I also wanted to try out Unity's Timeline with Spine animations. I believe I could do that with Spine Mecanim, but would I somehow be able to use the Timeline with SkeletonAnimation as well?


One more quick thing - I think there might be a typo in the documentation here. Either that or I'm interpreting it wrong:

The SkeletonMecanim component is an alternative to the SkeletonAnimation component, using Unity's Mecanim animation system instead of the Spine animation system. As the SkeletonAnimation component, it allows you to add a Spine skeleton to a GameObject, animate it, react to animation events, and so on.

Should that be SkeletonMecanim instead of SkeletonAnimation?

Thanks for the kind words, glad that you liked testing SkeletonMecanim so far!

Jamez0r escreveu

I also wanted to try out Unity's Timeline with Spine animations. I believe I could do that with Spine Mecanim, but would I somehow be able to use the Timeline with SkeletonAnimation as well?

Actually it is the other way around currently:
SkeletonAnimation provides a Timeline integration (vai a separate extension package):
spine-unity Runtime Documentation: Timeline Extension UPM Package

Unfortunately, SkeletonMecanim does not yet react to animation clips put into a Timeline track, Timeline support for SkeletonMecanim is yet to be implemented. There is a SkeletonGraphic implementation kindly provided by a user on the forum here.

Jamez0r escreveu

One more quick thing - I think there might be a typo in the documentation here. Either that or I'm interpreting it wrong:
.. "As the SkeletonAnimation component, it allows you to add a Spine skeleton to a GameObject" ..

This line was intended as: "Same as the SkeletonAnimation component, it (SkeletonMecanim) allows you to add a Spine skeleton to a GameObject. But thanks anyway for pointing that out, any feedback is always very much appreciated!

2 anos depois

Hi, I can't seem to get a smooth transition between layers when the animation ends.

I got 2 layers one with idle, run animations, and the other one with Attack animation (that holds keys for hand movement).

Example of my problem: Run animation on loop (run animation does have keyframes for hand movement as well)
and then a swing with a weapon on a different layer.
(it at least seems to blend at the start correctly, but the exit is just a quick frameskip to the run animation.

My animator has an empty state to which the attack animation (with keyframes for hand) transitions. We can even provide the character we are using if you need it.

It would be great if you provided an example either through spine boy, or some other character.

The problem here is that SkeletonMecanim does not apply the empty animation when transitioning to a Mecanim state without any clip assigned at the Motion field [1]. The simplest solution would be to create an animation with keys set to the setup pose in Spine and assign it as a clip at the Mecanim state.

[1] This is due to the nature how SkeletonMecanim works, by applying each layer's current animation at a given timepoint, instead of enqueing animations to AnimationState (which is done at the spine-unity Timeline implementation, which unfortunately would not work well with Mecanim states).