@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.