- Home /
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:
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;"
,
Answer by christiano9 · May 27, 2021 at 12:32 AM
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
Your answer
Follow this Question
Related Questions
animations problems 0 Answers
how to go to last frame of animation clip immediately? 1 Answer
Useing root motion with native unity animation 0 Answers
Automatically duplicate animation from imported file 2 Answers
How to Serialize an AnimationState 0 Answers