1
\$\begingroup\$

I'm using Animator and state for animating my charachter.

So, i've (example) an Idle state, associated to an Idle motion animation , and a Death State, associated to a Death animation.

But I've 5 possible animation for death so i would like to randomize death animation without create a state for each animation.

My State "Death" has a "Motion" variable. I would like to change at runtime this "motion" variable. Is it possible ?

Thanks

enter image description here

\$\endgroup\$
1
\$\begingroup\$

Quoting from Unity forums:

In 5.0 we introduced StateMachine Transition which can be used to generate random animation from a list see this blog for an example http://blogs.unity3d.com/2014/06/26/shiny-new-animation-features-in-unity-5-0/

in 4.x you can emulate this by creating a sub statemachine, with a first state that act like a selector; put a small clip(a few frame only) in this state that blend corrrectly to all your other random state, for each transition make sure that you don't have an exit time, you want to change as fast as possible from this selector state to your random state.

enter image description here

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ This answer would be even better if it included a quick summary of how to do this in the more modern versions (5 or later) rather than relying on an external link. \$\endgroup\$ – DMGregory Dec 10 '17 at 14:36
  • \$\begingroup\$ @DMGregory You are right. \$\endgroup\$ – S. Tarık Çetin Dec 10 '17 at 14:45

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.