When I try and run the following to play an animation, I receive the following in Unity
Animator.GotoState: State could not be found
UnityEngine.Animator:Play(String)
Test:OnMouseDown() (at Assets/Test.cs:27)
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32)
Invalid Layer Index ‘-1’
UnityEngine.Animator:Play(String)
Test:OnMouseDown() (at Assets/Test.cs:27)
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32)
`
public class Test : MonoBehaviour {
public GameObject Player;
// Use this for initialization
void Start () {
Player = GameObject.FindWithTag("Player");
}
// Update is called once per frame
void Update () {
}
public void OnMouseDown() {
string i1, i2, d;
int e;
Player = GameObject.FindWithTag("Player");
i1 = "Idle2Crouch_Neutral2Crouch2Idle";
i2 = "Idle_JumpDownLow_FlipOnHands_Idle";
e = Random.Range(1,3);
d = "i" + e;
Player.GetComponent<Animator>().Play(d);
}
`
Any help would be appreciated