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)