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.