I used Animation.Play() and it worked almost the way I wanted it to, but I needed to specify what animations to play, and when I added them in, Unity suddenly didn’t like what I was doing and gives me errors every time I try to use Animation.Play(). Anyone know what my problem is?
using UnityEngine;
using System.Collections;
using UnityEditor.Animations;
public class WorkerBehavior : MonoBehaviour
{
public enum State
{
Lazy, Working
};
public Animator Anim;
public void Start ()
{
Anim = GetComponent<Animator>();
}
public void Update()
{
if (Input.GetKey(KeyCode.Q) || (Input.GetKey(KeyCode.W) || (Input.GetKey(KeyCode.E) || (Input.GetKey(KeyCode.R) || (Input.GetKey(KeyCode.T) || (Input.GetKey(KeyCode.U) || (Input.GetKey(KeyCode.Y) || (Input.GetKey(KeyCode.I) || (Input.GetKey(KeyCode.O) || (Input.GetKey(KeyCode.P) || (Input.GetKey(KeyCode.A) || (Input.GetKey(KeyCode.S) || (Input.GetKey(KeyCode.D) || (Input.GetKey(KeyCode.F) || (Input.GetKey(KeyCode.G) || (Input.GetKey(KeyCode.H) || (Input.GetKey(KeyCode.J) || (Input.GetKey(KeyCode.K) || (Input.GetKey(KeyCode.L) || (Input.GetKey(KeyCode.Z) || (Input.GetKey(KeyCode.C) || (Input.GetKey(KeyCode.V) || (Input.GetKey(KeyCode.B) || (Input.GetKey(KeyCode.N) || (Input.GetKey(KeyCode.M))))))))))))))))))))))))))
{
Animation.Play("HumanoidIdle");
}
else
{
Animation.Play("HumanoidCrouchIdle");
}
}
}