- Home /
Animation constantly resetting?
Hey, all. I have a character with an animator that controls animations. The problem is, when I use the attack animations, it will constantly reset and never fire until I release the attack button- or it will go into a strange partial animation and reset again. What I'm trying to do is use the private bool attacking to detect if the animator is already set to "attacking". If I attach if( attacking == false)
under the Input Fire1 line, it seems to want to not animate at all, even just a bit, until I release the attack. I would use trigger, except it will eventually have new attack animations, and I want the animations to spam, similar to (I think it was) Jedi Knight: Jedi Academy. Hit the mouse to spam attacks until the attack bool - or whatever they used- is false.
if (Input.GetButton("Fire1"))
{
Anim.SetBool("attacking", true);
attacking = true;
StartCoroutine(AttackRoutine(1f));
}
}
IEnumerator AttackRoutine(float delay)
{
yield return new WaitForSeconds(delay);
Anim.SetBool("attacking", false);
attacking = false;
}
Have you tried changing Input.GetButton()
to Input.GetButtonDown()
Yes, I tried GetButtonDown. It only plays once and doesn't spam the attacks.