Play unity animation alternately

Hello,

i want to switch the animation when a trigger is pressed, but in my case when holding a button pressed it only playes the second one.

    bool isPlaying (string stateName) {
        var info = animator.GetCurrentAnimatorStateInfo(2);
        if (info.IsName(stateName) && info.normalizedTime < 1.0f) {
            return true;
        } else {
            return false;
        }
    }
    void updateAttack () {
        attackTimer -= 0.01f;
       
        if (interact.ReadValue<float>() == 1 && attackTimer <= 0) {
            if (!isPlaying("Attack 1") && !isPlaying("Attack 2")) {
                attackTimer = 0.5;
                if (attackIndex == 0) {
                    attackIndex = 1;
                    animator.SetTrigger("isAttacking2");
                } else {
                    attackIndex = 0;
                    animator.SetTrigger("isAttacking");
                }
            }
        }
    }

But why?
its inside update.

i checked if the animations are playing, a input from new input system and a very short attack delay.

But the animation is still the same when holding the button pressed.

The mistake could be interact.ReadValue() == 1
You should use Mathf.Approximately for float comparison.
Try if (Mathf.Approximately(interact.ReadValue<float>(),1.0f) && attachTimer <= 0){}

Sadly not working.
I think its a timing problem.

Edit:
[Solved]
Found out that the two animation-transitions has differend settings, one had “has exit time”, the other one not, i dont know why the checkbox was clicked, i setup both at the same way.