Search Unity

Multiple Animators or Layers?

Discussion in 'Animation' started by Corva-Nocta, Sep 23, 2013.

  1. Corva-Nocta

    Corva-Nocta

    Joined:
    Feb 7, 2013
    Posts:
    624
    I would like to create different animation sets depending on what item is being held. I am not very experienced with the mechanim system, I can get each animator to work for each individual item but I am unclear of how to bring them all together. I will be having too many items to put everything into 1 animator screen, so I am thinking I will have to do layers, but I am unsure.


    Just a quick example in case it is needed:
    Large item equipped-
    -slow walking
    -slow running
    -no dodging

    small item equipped-
    -fast walking
    -fast running
    -dodging possible


    If anyone is able to suggest what method would be best for this type of animation, that would be greatly appreciated! Just a simple nudge in the right direction, I will look up whatever tutorials and help I need from there :)
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,687
    This is just my suggestion, not gospel.

    Only have one animator, which means one animator controller.

    If you're using Unity Pro, use sync layers. For example, you could have an "abstract" Base Locomotion Layer and two sync'ed layers: Large Item Locomotion and Small Item Locomotion. When your character equips a large item, set the Large Item Locomotion layer's weight to 1 and the other layer to 0. The advantage of sync layers is that they let you work on an abstract level regardless of which implementation layer is currently active.

    If you don't have Pro, then your top-level animation state machine will be very simple, with just two sub-state machines: Large Item and Small Item. When the character changes equipment, it transitions between these two sub-state machines. Inside each sub-state machine, implement the full locomotion graph (walking, running, possibly dodging, etc.).

    I've used both approaches in real projects, and they both worked well.
     
  3. Corva-Nocta

    Corva-Nocta

    Joined:
    Feb 7, 2013
    Posts:
    624
    Ok I think I see what you are saying. It's a much cleaner version of what I was fearing I would have to do, but at least its a direction. My biggest fear with this is how complicated it will get since I would like to have something like 20+ items, but this should work

    I also do not have pro (yet!) But I will look in to the methode you have mentioned. Thanks for the help!
     
  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,687
    There are many ways to simplify the state machine.

    For example, you can use a layer for lower body and a layer for upper body.

    Say you're creating a medieval fantasy melee game. The lower body behavior might be the same regardless of whether you're using a sword, club, axe, or spear. But the upper body behavior might have different sub-state machines for each weapon type (slashing with a sword, thrusting with a spear, etc.). So you can have fewer overall states by separating lower and upper body into separate layers. Similarly, you can add an additive layer to handle crouching and hit reactions; you can apply it regardless of what weapon you're using. This way, you don't need to build crouching separately into each weapon's sub-state machine.

    Another way to simplify is to use blend trees. You can have a single blend tree for the attack state that blends on the weapon type. If the weapon type is 0, play the sword slash animation. If the weapon type is 1, play the axe chop animation. If the weapon type is 2, play the spear thrust animation, etc.

    And in the future we should hopefully have better script access to the animator controller so we can swap out clips and such. But with the blend tree described above you really don't need script access to achieve the same goal.
     
unityunity