Search Unity

Mecanim: How to play large lists of animations

Discussion in 'Editor & General Support' started by chronosapien, Apr 29, 2013.

  1. chronosapien

    chronosapien

    Joined:
    Feb 1, 2011
    Posts:
    73
    I need a way to play a specific animation from a large list of face animations in mecanim. As far as I know, the only way to play animations in mecanim is to set parameters through the animator on the object you're playing animations on. The problem is that the only paramters are bools, floats, ints, and vectors and I don't want to set up a massive tree that checks against each possible animation. What I would like to do is have a single node with a list of animations and pass it a string or clip reference of the animation to play.

    Does anyone have a better solution for playing one shot animations in mecanim from a large list?
     
  2. Chunks

    Chunks

    Joined:
    Jul 30, 2012
    Posts:
    4
    Unfortunately, you'd still have to set up all the transitions, but you could use an int as parameter. Each animation you want to play uses a different integer value. In your code, you could use an enum so that the code is intuitive... or you could set up a whole separate class with static ints. That might be easier to deal with if you have to do reorganization and re-ordering of animations.

    If you're familiar with Python, there's a cheap Python interpreter available from the asset store, and you could probably use it to set up all the transitions in your animator procedurally, rather than setting them all up by hand.