Hi everyone! I just found out that spine can let you export all the animation clips using the SkeletonMecanim, I think I can use with the Unity blend trees system to create a smooth transition for my 2D top down game. However, when I dragged the animation clips into the motion field somehow it overlay the sprite on each other. I don't know if I have done something wrong or it come from the way the animator handle the spine file.
SkeletonMecanim and Blend Tree
It seems like you are experiencing issues with using SkeletonMecanim and Unity's blend trees, where the animations are overlaying each other incorrectly. This could be due to how the animations are being handled in the blend tree setup. One potential issue is that the animations might not be intended for blended playback if the skeleton was created with separate skins per direction, as mentioned in the context. This can cause animations to look strange when played back with partial weights. To address this, ensure that your animations are compatible with blending and that the blend tree is set up correctly. You might also want to check if the animations are being applied correctly in the SkeletonMecanim setup and that the transition configurations in your Mecanim state are correct.
@khangng2001 Unfortunately SkeletonMecanim
comes with some limitations and additional requirements as described in this documentation section, like additional required keys. This is mostly due to different ways how Unity and Spine combine multiple animations.
When using blend trees, you should in the Mecanim Translator
component settings enable Custom MixMode
and set the respective layer's Mix Mode
to Match
:
https://esotericsoftware.com/spine-unity-main-components#Animation-Blending-Control
Note that in general SkeletonAnimation
, which uses AnimationState
, is recommended over SkeletonMecanim
as it behaves like the Spine Editor. SkeletonMecanim
can unfortunately only try to get an approximation of one system through using the other.
Harald Thank you for your reply. Based on your answer I have to tell my animator partner to do those things right? Cause I am a developer and I dont know much about animation at all
khangng2001 Cause my game is a 2D top down game and I think using blend tree will help me a lot in performing the animation of the character
khangng2001 Harald Thank you for your reply. Based on your answer I have to tell my animator partner to do those things right? Cause I am a developer and I dont know much about animation at all
Did you check out this section of my above posting, did it not resolve your issue? Note that that's a developer task, not an animator's:
Harald When using blend trees, you should in the Mecanim Translator component settings enable Custom MixMode and set the respective layer's Mix Mode to Match:
https://esotericsoftware.com/spine-unity-main-components#Animation-Blending-Control
khangng2001 khangng2001 Cause my game is a 2D top down game and I think using blend tree will help me a lot in performing the animation of the character
How did your animator set up the animations of each direction? Can they be blended so that the result is as desired when previewed in the Spine Editor's Preview window? Or did the animator design the animations so that only one directional animation can be played at any one time (i.e. not blending up and side animations at the same time)?
Please note that you need to work together with your animator to be on the same page, otherwise this will lead to a lot of frustration.
Harald Sorry for replying you late, the animator set up the anaimation for each direction by turning other directions off. For example, if the character goes down other top, left, and right direction will be turned off
@khangng2001 Sorry for replying you late
No need to apologize, your reply was not late at all!
khangng2001 the animator set up the anaimation for each direction by turning other directions off. For example, if the character goes down other top, left, and right direction will be turned off
Thanks for the clarification. If the directional animations are designed by your animator to be turned off completely, then it will not work as desired when playing both animations at the same time blending between them.
Note that for 4- or 8-direction animations it's also a valid approach to have multiple SkeletonAnimation (or SkeletonMecanim) GameObjects (e.g. up, down and right; mirroring right for left) and enable only the active direction's GameObject and disable the others.
If you want to use a single SkeletonAnimation GameObject for all directions, you could keep track of the current direction and as soon as it changes, and clear the animations on each track and set the animations of the new direction, using the previously playing TrackEntry
's trackEntry.TrackTime
to continue the animation at a certain timepoint if it shall not start anew from time 0.
With SkeletonMecanim
it's perhaps a bit more complicated to control as desired, as you would need to ensure that the transition duration is always 0 when transitioning from one direction animation to a different direction animation. Otherwise you will get blending between direction animations. One more solution could be to use multiple Mecanim animation layers, one for each direction, and set all but the active layer's alpha values to 0 and only the active direction's layer to 1. Still, you would likely need to mirror any left-direction animation from a right-direction animation, so some additional scripting and state-keeping remains.