Search Unity

Changing animator controller in script

Discussion in 'Scripting' started by wilsonc911, Aug 29, 2014.

  1. wilsonc911

    wilsonc911

    Joined:
    Aug 8, 2014
    Posts:
    9
    Is it possible to change the animator controller that an animator uses in a script? i want to run a different set of animations in certain situations or do i have to put it all in one animator controller and use variables there?
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Code (csharp):
    1.  
    2.        anim = GetComponent<Animator>();
    3. anim.runtimeAnimatorController = someController;
    4.  
     
    wilsonc911 likes this.
  3. wilsonc911

    wilsonc911

    Joined:
    Aug 8, 2014
    Posts:
    9
    Thanks!