In my game I need to animate my characters from a stance (looping animation), to a walking animation in a blend tree (“Locomotion”), to an attack animation, back to the stance state and back to the walking animation. I get the walking animations to play from scripts by using .SetFloat(“speedPercent”, 1, 0, Time.deltaTime);
I was using .Play(“stateName”); to play the stance and attack clips. But the behaviour of the animations does not work as i intend.
One aspect works, which is making the animator switch from boxing stance to doing the attack animation. But when trying to make it go back to the boxing stance and movement animations, it does not work. It appears to be stuck in the boxing stance state, unable to get to the blend tree.
This could be to do with the boxing stance being a looping animation, making in unable to move to the blend tree. I’m planning on having many stances the stances serve as alternate idle animations while the player picks an attack type, so they have to loop. Maybe i need something which triggers the boxing stance loop to be interrupted and move to the appropriate clip. I have looked into and experimented with bool and trigger parameter conditions to make the animations states transition to others, but i have been unsuccessful in getting it to work correctly. I think maybe i have some gaps in my knowledge and misconceptions about the correct way to use the unity animator.
I would appreciate any help people could give me on this problem.