- Home /
animation.Play (MissingComponentException: There is no 'Animation' attached to..
So, I have made an animation clip and attached it to a GameObject in my scene . then i wrote this script and attached it to the same GameObject
Code:
using UnityEngine;
using System.Collections;
public class startAnim : MonoBehaviour {
public AnimationClip hand_close_a;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (true)
animation.Play("hand_close_a");
else
animation.Stop("hand_close_a");
}
}
now whenever I try to run this code I get this error
MissingComponentException: There is no 'Animation' attached to the "close_hand" game object, but a script is trying to access it. You probably need to add a Animation to the game object "close_hand". Or your script needs to check if the component is attached before using it. UnityEngine.Animation.Stop (System.String name) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/Animations.cs:512) startAnim.Update () (at Assets/tutorial/scripts/startAnim.cs:24)
Did you actually assign an animation to the AnimationClip variable?
Answer by digO · Apr 28, 2014 at 04:07 AM
Well, you need to put an Animation into your gameObject, for that select your gameObject and click Add Component -> Miscellaneous -> Animation, now you have an animation attached to your gameObject, in the new animation window created you can put your animations, put "hand_close_a" into Animations and your script will work.
I did and now i don't get the error but still the animation doesn't play
Answer by Chris196 · Oct 27, 2015 at 11:55 AM
the animation state "Walk" could not be found . "Walk" must be marked as Legacy
Click your animation in project,in inspector right click and chose debug mode and check legacy.
Sorry i can't more speech English because i from indonesia.