Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

animation dose't play in scene

Discussion in 'Animation' started by albatool, Apr 28, 2014.

  1. albatool

    albatool

    Joined:
    Dec 27, 2013
    Posts:
    6
    I have made a small animation and attached it to an object in the scene the I attached a small script to that object to play the animation.
    however, when I try it out it gives me this error message
    this is my code
    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class startAnim : MonoBehaviour {
    5.  
    6.     // Use this for initialization
    7.     void Start () {
    8.        
    9.     }
    10.    
    11.  
    12.     // Update is called once per frame
    13.     void Update () {
    14.  
    15.             animation.Play();
    16.  
    17.     }
    18. }
    and this is a screen shot of the object with the animation and code attached with it

    $unity.png
     
  2. Goss

    Goss

    Joined:
    Dec 6, 2012
    Posts:
    11
    animation is the legacy animation system. You're using Mecanim. Try Animator animator = GetComponent<Animator>();

    Then you can do animator.Play("close_hand_a");

    Animation = Legacy
    Animator = Mecanim

    Also note when you import your models, you have to import them using the Mecanim setting and setup the avatar target system.
     
    Last edited: Jun 18, 2014