I thought about what was said in a previous class, that trigger is smart to get back to “off” state after the animation, and I figured out that after triggering “stop attack” the following animation hasn´t get to an end, so the trigger keep its “on” state.
So I tried to reset the trigger every time I initiate an attack, and it worked fine!
Look at the reset call in source code:
private void AttackBehaviour()
{
if (timeSinceLastAttack < timeBetweenAttacks) return;
animator.ResetTrigger("stopAttack");
// This will trigger the animation hit event
animator.SetTrigger("attack");
timeSinceLastAttack = 0f;
transform.LookAt(target.transform.position);
}