- Home /
Question by
JustinCeledio · Mar 27, 2018 at 12:08 AM ·
c#errorerror messageplay
Can't Get animation.Play to work
I get this error: Error CS1061: Type UnityEngine.Component' does not contain a definition for
Play' and no extension method Play' of type
UnityEngine.Component' could be found. Are you missing `UnityEngine.Playables' using directive? (CS1061) (Assembly-CSharp). When typing get animation.play and I don't understand why. Here is my code:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityStandardAssets.CrossPlatformInput; public class RobotController : MonoBehaviour {
private Rigidbody rb;
private Animation anim;
// Use this for initialization
void Start () {
rb = GetComponent<Rigidbody> ();
anim = GetComponent<Animation> ();
}
// Update is called once per frame
void Update () {
float x = CrossPlatformInputManager.GetAxis ("HOrizontal");
float y = CrossPlatformInputManager.GetAxis ("Vertical");
Vector3 movement = new Vector3 (x, 0, y);
rb.velocity = movement * 4f;
if (x != 0 && y != 0) {
transform.eulerAngles = new Vector3 (transform.eulerAngles.x, Mathf.Atan2(x,y) * Mathf.Rad2Deg ,transform.eulerAngles.z);
}
if (x != 0 || y != 0) {
animation.Play ("walk");
} else
animation.Play ("idle");
;}
}
Comment
Your answer
Follow this Question
Related Questions
Error opening project.,Error opening project 0 Answers
how to fix Index Out Of Range Exception 1 Answer