Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Help with array of animations.

Discussion in 'Animation' started by dotan19586, Jul 10, 2018.

  1. dotan19586

    dotan19586

    Joined:
    Dec 19, 2016
    Posts:
    3
    Hello all!

    I'm trying to build a step by step guide to a 3d model.
    I want to put a "next" button that plays every next step.
    What I thought is to make an array of animation and with every "next" clicked it plays the next animation.
    I found on the web a nice function that does that:

    Code (CSharp):
    1.     public Animation ReferenceToAnim;
    2.     public AnimationClip[] clips;
    3.     int _currClip = 0;
    4.  
    5.    
    6.     public void OnAnimationComplete()
    7.     {
    8.         _currClip++;
    9.         if (_currClip == clips.Length) return;
    10.         ReferenceToAnim.clip = clips[_currClip];
    11.         ReferenceToAnim.Play();
    12.     }
    When I attach this script to something I need to assign the "ReferenceToAnim" from type Animation, and unity don't let me.

    Can anyone explain the difference between Animation and AnimationClip?
    What kind of animation can I drag to the Animation type?
    With AnimationClip I can drag any animation that I created.

    Thanks!!
    Dotan.