- Home /
Animator.Play(state) gives error
This problem is probably insanely simple, but I haven't been able to shake it. I am using Animator.Play() to perform a attack animation, the reason I am using Animator.Play as opposed to Animator.SetTrigger() is that I need the animation to be reset each time the player performs the attack.
weaponAnimator.Play("isFiring", 0);
The above line of code gives me the warning: "Animator.GotoState: State could not be found" I tried not specifying the layer because I thought that maybe since the defult for the argument "layer" is negative the transition layer might be -1.
To be extra clear I tried this:
weaponAnimator.Play("isFiring");
and this...
weaponAnimator.Play("isFiring", 0, 0.0f);
Is it possible the the animation is faulty in some way? because I notice a seperate issue that the animation in game is not the same as the one in the animation preview window.
Your answer
![](https://koobas.hobune.stream/wayback/20220612114852im_/https://answers.unity.com/themes/thub/images/avi.jpg)