Rather often the animator fails to play an attack animation.

Hello, I’m using Unity 2017.2.2p1 and rather often the animator fails to play an attack animation; if I check the name of the current state every frame, it actually says that it is playing the correct animation and it even fires the event at the end of the animation, not the one in the middle though.

The Idle animation has 2 frames per second and I activate the transition to the attack animation with a bool. As I said, the character stays in Idle and doesn’t attack, but the event at the end of the attack animation is fired, which is the one that turns the bool false and let the animator transition back to Idle.

It happens more often during the running animation, a 6 frame loop animation. I move the character with translate inside the Update() and send every frame the velocity to the Animator to transition from Idle to Run and back if the velocity is greater or less then 0.1 .
When I want to attack, I stop the player input by turning a bool to true, check if I can attack, set the velocity to 0 and transition to Idle, yield there for 0.1 seconds and then set the bool for the attack animation to true.
As a result the character doesn’t stop running and doesn’t attack…but again, the animator tells that the states parameters are called correctly, that the states are correct (for instance it writes that it’s playing the Idle animation 6-8 times during the yield) and finally it fires the last event that resets the ability to attack, but it ignores the event in the middle which is the one that spawns the graphics and sound effects.

It’s completely ruining the combat and I spent a day and a half trying to fix it and I don’t know what else to do.

Could it be a bug in Unity?
I didn’t update to Unity 2017.3 because was messing my UI and I was close to the release of the game.

I could really use some help, thanks.

Have you set made sure that the Idle animation node haven’t got a fixed time set? That would have it do the entire animation before going on to the next node.

Hello PGJ, do you mean the “Has Exit Time” option? Here’s some screenshots.

Idle animation.

Transition from Run to Idle.

Transition from Idle To Attack.

Thanks.