Search Unity

Loading animations dynamically seems overly complicated

Discussion in 'Scripting' started by Shadoninja, May 8, 2018.

  1. Shadoninja

    Shadoninja

    Joined:
    Nov 12, 2013
    Posts:
    26
    I have 3 different animation clips. I want to choose one of them at runtime and load that into the Animator. I expected the code required for this to look something like this:

    Code (CSharp):
    1. animator = GetComponent<Animator>();
    2. animator.clip = PublicallyAssignedAnimationClip01;
    3. animator.play();
    But this isn't how it works and the online examples do some crazy custom code to get this to work. Am I missing something really obvious?
     
  2. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
  3. Shadoninja

    Shadoninja

    Joined:
    Nov 12, 2013
    Posts:
    26
    That manual post is incredibly helpful.