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 Answer 1

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

\$\endgroup\$
2
  • \$\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
    Commented Dec 10, 2017 at 14:36
  • \$\begingroup\$ @DMGregory You are right. \$\endgroup\$ Commented Dec 10, 2017 at 14:45

You must log in to answer this question.

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