Thanks! Randomly I found getCurrent in another forum thread, but I will try it.
What i'm doing here is to check if the specific animation is already set, and if not, set it.
I'm using a custom state on the monobehavior like IDLE/WALK, then the method i mentioned above is checking what the state is, and switching animation if it's not already set.
Is this something that could be wasteful to resources? This code is run on each frame, and the ActionState is set from different places.
Thanks in advance for your advice!
case ActionState.IDLE:
// When in attack mode, show idle attack animation
if (
(subState == SubState.ATTACK || subState == SubState.ATTACK_WAIT)
&& skeletonAnimation.AnimationName != AttackWaitAnim.Name) {
// Attack idle
SetAnim(0, AttackWaitAnim, mix: defaultMixDuration, loop: true);
} else if (subState == SubState.IDLE && skeletonAnimation.AnimationName != IdleAnim.Name) {
// Normal idle
SetAnim(0, IdleAnim, mix: defaultMixDuration, loop: true);
}
break;
case ActionState.WALK:
if (WalkAnim != null && skeletonAnimation.AnimationName != WalkAnim.Name) {
SetAnim(0, WalkAnim, mix: defaultMixDuration, loop: true, alpha: 1, timeScale: walkAnimSpeed);
}
break;
}