I can't get my animation to play. can someone help

every time i press play then press Fire1 to play my animation it gives me two warnings, they are “Animator.GotoState: State could not be found
UnityEngine.Animator:Play (string” And “Invalid Layer Index ‘-1’
UnityEngine.Animator:Play (string)” My code is:


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

public class AttackSequence : MonoBehaviour

{
public GameObject Tanjiros_Nirichin_sword;

// Update is called once per frame
void Update()
{
    if (Input.GetButtonDown("Fire1"))
    {
    AttackAnim();  
	}
}

void AttackAnim ()
{
 Tanjiros_Nirichin_sword.GetComponent<Animator>().Play("AttackAnimation");
}

}


And yes i am making a demon slayer game because you can clearly see this in my code

“public GameObject Tanjiros_Nirichin_sword;”

,

I fixed my problem. but… i can only play the animation once after that if i push the button to activate it it does nothing i will attach a video of it P.S. i will ad a debug.log so you know when am pushing the button.

Video Of My Problem /

file:///C:/Users/Christian/Downloads/New%20Unity%20Project%20(2)%20-%20Testing%20-%20PC,%20Mac%20&%20Linux%20Standalone%20-%20Unity%202020.3.1f1%20Personal_%20_DX11_%202021-05-26%2017-34-15.mp4