How to guarantee animation plays all the way through?

Hi,

I’m making an RPG in Unity 2D. I’m animating my player character using the mechanim system. He has basic animations like “Idle”, “Attack”, “BlockingAttack”, etc. I’m also using animStates(int) to designate transitions from my controller script to the animator. I notice that with many of my animations, they transition to the next without completing all the way through. How can I remedy this? I should mention that each animation has a different number of frames, does this matter? Here is a sample of how I handle animations in my controller script:

//regular attack
        if((_attack) && (!blocking))
        {
            _animator.SetInteger("AnimState", 1);
        }
        //blocking attack
        else if((blocking) && (_attack))
        {
            _animator.SetInteger("AnimState", 2);
        }
        //overheadstrike
        else if(_overheadStrike)
        {
            _animator.SetInteger("AnimState",3);
        }
        //idle
        else
        {
            _animator.SetInteger("AnimState", 0);
        }

Perhaps it’s simply a matter of manually modifying transitions, or perhaps implementing a wait for animation to complete function. Idk.

Thanks!

Maybe this can help: