'Attack speed messing up animation

if (Input.GetMouseButtonDown(0))
{
    if (currentanim >= 3)
    {
        currentanim = 1;
    }
    
    if (swordanimactive == false)
    {
        if (swordblockanimactive == 1)
        {
          currentanim = currentanim + 1;
          //the problem seems to be here
          Swordcontroller.speed = attackspeed;
          Swordcontroller.SetInteger("attackindex", currentanim); 
          Swordcontroller.SetTrigger("attack");     
        }
    }
}

The problem is when I set the attack speed over 1 (regular speed), after a few clicks it just stops working. I have no idea what causes this and I don't know how to fix it since I just implemnted this new animation system. Also, the current animation is just because there are 3 sword animations. However, if I set it to only one animation it works perfectly fine. When I use 3 different animations it doesn't work.



Solution 1:[1]

First of all, I do not really know how you set up the animator, but I recommend this structure.

Multi Animation Animator

Has Exit Time

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 KiynL