1
\$\begingroup\$

I am trying to set the Controller of an Animator during runtime using a script.

When I click on the dot in the inspector manually, I can choose one called "Standard Walk", but have not found a way to automate it.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

You should be able to swap out controllers at runtime by changing the animator's runtimeAnimatorController property.

\$\endgroup\$
2
  • \$\begingroup\$ Thank you for your help! It works, but how do I set it to one of the existing ones, which I can select when I do it manually? \$\endgroup\$
    – GreenJoFlo
    Commented Jan 4, 2021 at 20:19
  • \$\begingroup\$ By having a reference to it. From your use of the plural, you would probably want whatever script is doing this to take in an array of AnimatorController as a public field, and then you pick which one to assign. Alternatively, you could use Resources.LoadAll to dynamically load at runtime all the controllers you need. \$\endgroup\$ Commented Jan 4, 2021 at 20:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .