Identifying and fixing bug

I thought about what was said in a previous class, that trigger is smart to get back to “off” state after the animation, and I figured out that after triggering “stop attack” the following animation hasn´t get to an end, so the trigger keep its “on” state.
So I tried to reset the trigger every time I initiate an attack, and it worked fine!
Look at the reset call in source code:

    private void AttackBehaviour()
    {
        if (timeSinceLastAttack < timeBetweenAttacks) return;
        animator.ResetTrigger("stopAttack");
        // This will trigger the animation hit event
        animator.SetTrigger("attack");
        timeSinceLastAttack = 0f;
        transform.LookAt(target.transform.position);
    }
1 Like

Well done fixing the bug :slight_smile: That shows real progress!

Well done! This, along with the reciprical ResetTrigger(“attack”); when we abandon an attack ensure that both triggers should always work as intended.

Privacy & Terms