animation states and triggers

I have a character that has 3 animation states that are started using a trigger. There are two special attacks, which happen upon X chance when clicking, and then the default attack. Everything works fine when clicking fairly rapidly, but if I spam click as fast as I can, the special attack states will never start, then when I stop clicking, both the special attack states play back to back even with no clicks, almost like they got queued up somehow.

if (Input.GetMouseButtonDown(0)) {
            if (animator) {
                if (SmashAttackChance()) {
                    animator.SetTrigger("smash");
                } else if (NukeAttackChance()) {
                    animator.SetTrigger("nuke");
                } else {
                    animator.SetTrigger("attack");
                }
            }
        }

Trigger’s get set true in the animator like a boolean, and then get “consumed” by the animation transition and set false. That is mostly likely the queuing behavior you’re seeing.

You may need to be using ResetTrigger to manage your animation interrupts, or code with better control over click spamming, not allowing further clicks until a resolution is reached depending on your game design.

1 Like