thcha Is this the right way to implement it?
Or is it the right way to set only states such as idle and move and get the state from the code and set the direction?
As Spinebot mentioned, there is no single right way. In general having a Mecanim subtree with single states for 8-direction movement is a valid approach. I don't see why it would not scale well with 16-direction movement (creating all the animations would likely be the larger effort).
Note however that the hybrid approach shown in "Mecanim Logic SkeletonAnimation view" of controlling animation via Mecanim while in the end targeting a SkeletonAnimation
component is not the primary recommended approach. This always comes with some limitations, as it's mapping one limited system onto another. In general we always recommend directly using the SkeletonAnimation
component and SkeletonAnimation.AnimationState
if you can, and issuing the respective AnimationState.SetAnimation()
calls via code. Your movement components can use AnimationReferenceAsset
object references if you prefer drag-and-drop assignment of animations, or have [SpineAnimation][SerializeField] string animationUp;
if you prefer selecting animations from a list.