Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Can't Get animation.Play to work

$
0
0
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 (); anim = GetComponent (); } // 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"); ;} }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>