Search Unity

Play animation from AnimationClip

Discussion in 'Animation' started by DarkEcho, Jun 16, 2018.

  1. DarkEcho

    DarkEcho

    Joined:
    Jul 7, 2014
    Posts:
    233
    How would I play a stored animationclip?

    ive tried the below but unity dosnt recognise .clip (legacy?)

    Code (CSharp):
    1. public AnimationClip harvestAnimation;
    2.  
    3.     public void Activation (Animator animator) {
    4.         animator.clip = harvestAnimation;
    5.         animator.Play();  
    6.     }
    7.  
    EDIT:
    Clarification:
    The player will interact with a gameobject and click on it. The player will play a animation stored in the gameobject. Each gameobject will serve a different purpose, therefore will have different animations. The best way I can think of accomplishing this is to put the required animation to be played in the gameobject. The above script is the gameobject script.
     
    Last edited: Jun 17, 2018
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
  3. DarkEcho

    DarkEcho

    Joined:
    Jul 7, 2014
    Posts:
    233
  4. DarkEcho

    DarkEcho

    Joined:
    Jul 7, 2014
    Posts:
    233