Error message when calling Animator.Play(): Invalid Layer -1 ?
I am trying to do a simple animation with a simple state machine, but Unity prints out an error message:
Invalid Layer Index '-1' UnityEngine.Animator:Play(String, Int32, Single)
I have printed out all the layer IDs and they are all "-1", which should work. But, unfortunately, Unity keeps prints out the same error above.
I am using the latest version of Unity 5.5.2
Here is the code:
using UnityEngine;
public class Thanh_Space_Man : MonoBehaviour {
public Animator anim;
// Use this for initialization
void Start ()
{
anim = GetComponent<Animator> ();
}
// Update is called once per frame
void Update ()
{
if(Input.GetKeyDown("1"))
{
anim.Play ("Run_Rifle_Forward", -1, 0f);
}
if(Input.GetKeyDown("2"))
{
anim.Play ("Idle_Rifle_01", -1, 0f);
}
}
}
Your answer

Follow this Question
Related Questions
Animation generating incorrect and impossible values? 0 Answers
How can I animate a button that is a child of a canvas? 1 Answer
How to let animation play to the end before playing the next one using button 2 Answers
Animation event call the function but the animation isn't playing 0 Answers
Rootmotion orientation won't change 0 Answers