1
\$\begingroup\$

is there a way in Unity to access the Motion clip of an Animator State and change it at runtime via script? I am trying to do a character shop in my 2D game. My idea is, when i click a GUI button it would just select different motion clips but the states would stay the same. It's just a simple Jump and Idle state, parameters dont change. I just want to feed in different animation clips for different characters.

enter image description here

\$\endgroup\$
2
\$\begingroup\$

Yes, but you would do this via the Mechanim state machine. Create a transition and set it to change via a Trigger.

enter image description here

Doing it this way, when you want to swap animation states, you simply do this:

Animator.SetTrigger ("Swap");

If you want to set the Animator Motion directly, it is a little more complicated. You will need to create Animation Controllers, and then swap them using the AnimatorOverrideController.

\$\endgroup\$
1
  • \$\begingroup\$ I used the AnimatorOverrideController and it works! Thank you. \$\endgroup\$ – Richarrd82 Sep 26 '16 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.