Animation bool stop

Hello i need help me script not stop animation bool help me pls here is script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Attack : MonoBehaviour
{
    // Start is called before the first frame update

    Animator anim;
    void Start()
    {
        anim = gameObject.GetComponent<Animator>();
    }

    // Update is called once per frame
    public void attack()
    {


        anim.SetBool("Attack", true);

     



    }

    private void Update()
    {
        if (anim.GetCurrentAnimatorStateInfo(0).IsName("Attack"))
        {
            anim.SetBool("Attack", false);
        }
    }
}

Update runs every single frame. Is that what you want?

Also, is your animation set to loop?

Parameters in an animator don’t control whether an animation is currently running, only whether the animator should transition to that state. Setting a boolean to False in an animator doesn’t cause the animation to stop. It just stops state transitions into that state. If you want the animation to stop, either call other animator methods to manually interrupt the current clip, or better, set another property to true to transition to another state in your animator.

1 Like