- Modifié
use SkeletonMecanim How to mix layer?
Mecanim has 2 layers, 0 LAYER is WALK and 1 LAYER is attak
use SkeletonAnimation I can use SetEmptyAnimation But I use Mecanim Add an empty state Mixing will not work
I can't speak English SORRY
Unfortunately the way how SkeletonMecanim
applies animations is different from what AnimationState does in SkeletonAnimation
.
If you see the last animation being applied without end, you have disabled Advanced
Auto Reset
in the SkeletonMecanim
Inspector:
Auto Reset. When set to true, the skeleton state is mixed out to setup pose when an animation finishes, according to the animation's keyed items. This may be especially important when an animation has changed attachment visibility state: when mixed out, attachment visibility will change back to setup pose state, otherwise current attachment state is held until another animation has a key set at the respective attachment timeline.
If you see the animation ending, but the ending is too quick (an immediate cut), then you are encountering the following limitation of SkeletonMecanim
:
From the documentation here:
Required Additional Keys
To smoothly mix out a timeline state (e.g. bone rotation) from one animation to the next, the second animation requires an additional key at the first frame when in setup pose. Otherwise the previous animation would leave a leftover timeline state. This is one of the drawbacks of SkeletonMecanim compared to SkeletonAnimation.
So in order to mix out your animation, the following animation needs a key at the same timelines as the animation to be mixed out.
Thank you for your reply
The character on the left uses skeletonmecanim without transition The character on the right has a transition using skeletonanimation
second animation requires an additional key :think: second animation is an empty animation (New State Node) How to add additional keys 。
XiaoFan a écritHow to add additional keys 。
In the Spine Editor, you need to create an animation (the "empty" or "mix-out" animation) that keys the same bones as your to-be-mixed-out animation (in this case, as the shoot animation). Basically you need any other animation playing that keys the bones again, otherwise the previous animation's state will not be overwritten by anything and left as-is.
Unfortunately these limitations are cumbersome, which is why we recommend to use SkeletonAnimation
instead of SkeletonMecanim
if possible. Another solution would be to use a Mecanim-wrapper workflow as shown in the example scene Spine Examples/Other Examples/StateMachine SkeletonAnimation/Mecanim Logic SkeletonAnimation View
.
Harald a écritXiaoFan a écritHow to add additional keys 。
In the Spine Editor, you need to create an animation (the "empty" or "mix-out" animation) that keys the same bones as your to-be-mixed-out animation (in this case, as the shoot animation). Basically you need any other animation playing that keys the bones again, otherwise the previous animation's state will not be overwritten by anything and left as-is.
Unfortunately these limitations are cumbersome, which is why we recommend to use
SkeletonAnimation
instead ofSkeletonMecanim
if possible. Another solution would be to use a Mecanim-wrapper workflow as shown in the example sceneSpine Examples/Other Examples/StateMachine SkeletonAnimation/Mecanim Logic SkeletonAnimation View
.
thanks Let me try Mecanim Logic SkeletonAnimation View
Harald a écritXiaoFan a écritHow to add additional keys 。
In the Spine Editor, you need to create an animation (the "empty" or "mix-out" animation) that keys the same bones as your to-be-mixed-out animation (in this case, as the shoot animation). Basically you need any other animation playing that keys the bones again, otherwise the previous animation's state will not be overwritten by anything and left as-is.
Unfortunately these limitations are cumbersome, which is why we recommend to use
SkeletonAnimation
instead ofSkeletonMecanim
if possible. Another solution would be to use a Mecanim-wrapper workflow as shown in the example sceneSpine Examples/Other Examples/StateMachine SkeletonAnimation/Mecanim Logic SkeletonAnimation View
.
HI Use SkeletonAnimation Blend Tree Not working again ...
I'm sorry to hear that you're facing troubles again. Unfortunately there is no direct equivalent to a Blend Tree node available in the Spine API (and thus in AnimationState), so I'm afraid to say that using a Blend Tree node with the Mecanim Logic SkeletonAnimation View
example setup is not supported.
If you need Blend Tree state nodes as well, you unfortunately have to use SkeletonMecanim
. In order to smoothly mix-out an overlay layer 1 animation (e.g. gun-grab
), you can then either:
-
a) Create a mix-out animation at your skeleton in the Spine Editor which keys the same bones as the to-be-mixed-out (
gun-grab
) animation on layer 1 (e.g.gun-holster
which reverses any changes made by thegun-grab
animation). -
b) Key the same bones on your base layer animations (e.g. at your
walk
animation key the arm bones) and transition the layer 1 (gun-grab
) animation to anempty
animation. So that when the layer 1 (gun-grab
) animation ends and transitions to an empty animation, the base layer animation (walk-arms-keyed
) applies its keys and does not leave any leftover state of the layer 1 (gun-grab
) animation. Due to behaviour of the Unity Mecanim API, you need to create anempty
animation in the Spine editor (a new animation without any keys) and assign it at your empty state, because unfortunately a state with a blankMotion
property (None
) leads to the clip weight always being 1 of the previous state.
Please let us know if anything of the above setup remains unclear. We are sorry that this is a bit complicated. :wounded:
Harald a écritI'm sorry to hear that you're facing troubles again. Unfortunately there is no direct equivalent to a Blend Tree node available in the Spine API (and thus in AnimationState), so I'm afraid to say that using a Blend Tree node with the
Mecanim Logic SkeletonAnimation View
example setup is not supported.If you need Blend Tree state nodes as well, you unfortunately have to use
SkeletonMecanim
. In order to smoothly mix-out an overlay layer 1 animation (e.g.gun-grab
), you can then either:
a) Create a mix-out animation at your skeleton in the Spine Editor which keys the same bones as the to-be-mixed-out (
gun-grab
) animation on layer 1 (e.g.gun-holster
which reverses any changes made by thegun-grab
animation).b) Key the same bones on your base layer animations (e.g. at your
walk
animation key the arm bones) and transition the layer 1 (gun-grab
) animation to anempty
animation. So that when the layer 1 (gun-grab
) animation ends and transitions to an empty animation, the base layer animation (walk-arms-keyed
) applies its keys and does not leave any leftover state of the layer 1 (gun-grab
) animation. Due to behaviour of the Unity Mecanim API, you need to create anempty
animation in the Spine editor (a new animation without any keys) and assign it at your empty state, because unfortunately a state with a blankMotion
property (None
) leads to the clip weight always being 1 of the previous state.Please let us know if anything of the above setup remains unclear. We are sorry that this is a bit complicated. :wounded:
hi SkeletonMecanim It supports Blend Tree (Use Animation.Apply() API ) This is useful when creating transition animations
such as walk => run Use speed parameters to control ( There are many variations in the speed parameters of the game logic ) In the future, it might be useful to add an API that can play multiple animations simultaneously :hmm:
Yes, you are absolutely right about that, it would definitely make sense to support something similar to a blend tree node at the AnimationState API. Currently changing blend weights back and forth (using e.g. a speed parameter) at simultaneously played animations would require having the simultaneous animations on multiple tracks, and changing the TrackEntry alpha values accordingly. While this is technically possible, admittedly it's more of a workaround and not comfortable to use that way.