sarahnorthway

I'm using SkeletonMechanim and an Animator. I want to move smoothly between an idle animation and a run animation based on the speed the player is moving, so the character will walk at slow speeds. I set up an Animator with two layers, each with a single state: Idle Layer (top) and Run Layer (bottom). I set the Weight of the bottom run layer to 50%.

It works - the two layers are correctly blended (well mostly correct).

But when I SWAP the two - whether I drag the Run Layer to the top, or switch the clips in the two layers so the Run Layer contains the idle and Idle Layer contains the run animation, it stops working. The bottom layer is completely ignored regardless of its Weight. So Idle can be blended onto a base of Run, but not the other way around. This is also true for my up, down, and right facing animations.

I can't imagine why this might be, but it was a pain to figure out. Is this somehow by design?

My animations:

vfwOl8xKSg.gif

U0Rnbsb4D6.gif

M8f5Puv95y.gif


My setup using spine-unity-3.8-2020-02-12.unitypackage (should be 50/50 but shows 100% run because Run Layer is on top):

Unity_5s3wsACxx4.png
添付ファイルを見るにはパーミッションが必要です
sarahnorthway
  • 記事: 6

Harald

sarahnorthway さんが書きました:(should be 50/50 but shows 100% run because Run Layer is on top):
I do not quite understand why it should be 50/50? The bottom-most layer is applied first, then the layers on top are replacing the animation pose (where keys exist), in your case with weight 1.0.

Layer order should matter with normal Unity Mecanim animations as well, being evaluated bottom to top, just as Photoshop layers.

Regarding using layers: It is rather uncommon to use separate layers to switch from run to idle animation - have you considered using a Blend Tree state for the run animations? Typically I would assume you won't want run and idle play at the same time, which would qualify them as separate states on the same layer.

Your game looks very nice BTW! :)
アバター
Harald

Harri
  • 記事: 1514

sarahnorthway

Thank you!

You're right - I had followed some out of date tutorial, and blend trees are the better way to blend walk > run, with the same end result. I've switched to blend trees and they work correctly - it doesn't matter which layer is on the top or bottom, it will blend 50/50. Switching to blend trees also fixed an issue where blending resulted in bizarre over-stretching.

Mechanim layers are definitely applied from top to bottom though, the opposite of Photoshop. In my screenshot the top (Run Layer) is the base - it's weight is pinned to 100% and can't be changed. The bottom (Idle Layer) is applied over the top by 50% but (incorrectly) had no effect. If I flipped them (top=idle=100%, bottom=run=50%) it worked. Some mysteries may never be solved...
sarahnorthway
  • 記事: 6

Harald

Glad to hear it's working as desired now.
sarahnorthway さんが書きました:Mechanim layers are definitely applied from top to bottom though
You are of course right, that was my mistake - the first layer (reasonably called Base Layer by default and having a fixed weight of 100%) is at the top and the layer stack grows downwards.
アバター
Harald

Harri
  • 記事: 1514


Return to Unity