Search Unity

What's the correct arrangement of animator layers for a typical rpg character?

Discussion in 'Animation' started by Nanako, Mar 19, 2015.

  1. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    i need a little help planning this out.

    So i have a character. he may or may not have a weapon in his hands, at any given time.

    He walks, runs, sprints (i have a blend tree for that), he stands relaxed, he jumps, he crouches.
    When he's got a weapon in his hand, he may do all of that stuff too, and mostly only his upper body changes, although when standing still he might have a different pose. And he'll also have a "weapon ready" pose when he's recently been hitting things with it.

    And then at completely different times, he might have a very different weapon, which requires its own overriding set of animations

    The way i've done it so far, i have a base layer which has two statemachines, onGround and inAir.
    The onground one has two states at present, Standing idle (without weapon) and locomotion (which is the blend tree with walk/run/sprint)

    I've got a Readiness layer that i was going to use for weapon poses, but now i'm not so sure how the overriding should work

    And ive got an upperbody layer, which i think, i should use for weapon animations that only use the upper body, and thus allow the legs to move normally while walking.

    But i'm thinking that only overriding the upper body while standing still, will look odd. I'd like weapon animations to use the whole body if the character isn't moving, but for the lower body part of them to not take priority over walking/running.

    And i'd like the weapon idle/ready poses to entirely replace the unarmed idle/ready poses.

    And at this point it kind of feels like a mess, i'm not sure entirely what i want. I could really do with examples and demonstrations
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Hi,

    Justin at Opsive posted a good description (including screenshots) of the animator controller in Third Person Controller:

    Description: Third Person Controller (Third Person Shooter, Adventure, RPG, etc)

    It might give you some ideas.

    For my own projects, early on I used sync layers, but it turned out they're not quite appropriate for this application. With sync layers, the states should be the same length, and you can't add one-off states to a specific layer.

    Rather than using layers for different weapon modes, I just have these layers:
    • Base
    • Upper Body
    • Head
    • Additive
    • Additive Reaction
    The Base layer has a sub-state machine for each weapon. You're going to walk differently with a spear than with a bow. The sub-state machines don't connect. Instead, I use CrossFade to switch between them. When I make a new weapon state, I copy-and-paste from an existing one and then customize it. There may be a bit of duplication, but at least I have full control of the appearance. I went with a single, shared inAir sub-state machine, but if I decide in the future that I need different inAir behavior for each weapon mode, I'll have to move this into each weapon's sub-state machine. So the top level of this layer is just a collection of unconnected sub-state machines, one for each weapon and another for inAir.

    The Upper Body layer works the same way.

    The Head, Additive, and Additive Reaction layers aren't weapon-specific. Head is for head motion and facial expressions (although a lot of head motion is IK controlled instead). Additive is for additive animation like slouching. Additive Reaction is for things like hit reactions.

    I also use blend trees fairly heavily, not only to blend idle, walk, run, and sprint, but to work personality into it as well, for example by blending from a dainty walk to a macho strut to an ogrelike stomp.

    What if you use these layers:
    • A t-pose base layer at weight 1 (so all bones have some value defined),
    • A whole body layer
    • An upper body layer
    When walking/running, keep the whole body layer's weight at 1.

    When not moving, allow the whole body layer's weight to drop to 0 when the upper body is doing a "whole body" animation.

    I haven't tested this; just a thought.
     
    Last edited: Mar 20, 2015
  3. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    More thoughts:

    i've got a hammer stand animation:


    And a jogging animation



    What i'm thinking of doing, is using the standing animation above, with an avatar mask that makes only the arms be influenced, and apply it with 1.0 weight to override everything else. i'll play that during various animations, like the jogging, and it should give the right arm position without needing to go and make a whole new hammer running anim, right?

    how feasible is this idea
     
  4. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    also is it possible to set avatar masks on a per-animation basis? because using the idea, i have some weapons where i'd want to override the entire upper body and not just the arms

    maybe if i make seperate versions of the animation with no keyframes in the areas i dont want to use?
     
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Here's the non-answer everyone hates: It's depends. :) For the example above, I don't think it would look right. In the hammer stand animation, he's holding the hammer in place with both hands. If you were to play that on the upper body while playing the jog animation on the legs, it wouldn't look right. Notice in the jog animation he's holding the hammer in one hand and swinging his arms. For something like a bow and arrow that might be held in the same position while standing or jogging, you might be able to get away with it.

    If you have an avatar mask on an animation and an avatar mask on an animator controller layer, both of them apply. So if your layer's mask only includes the arms, the most the individual animation will be able to control will be the arms, not the entire upper body.
     
  6. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    this sounds good, that's what i'd like. How do i put an avatar mask on an animation though? i know how to do it for an animator layer
     
  7. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    I totally agree with TonyLi. Masking the upper body will cause the upper body to look stiff and incorrect. For a 2 handed weapon walk/run the entire upperbody moves/sways back and forth when the character walks. Additionally the upper body is very unique for 2 handed weapons, depending upon the weight, length, and hand position.

    I know your trying to get a great setup to avoid over-creating animations, but I think masking the upper body during very common animations could result in a lesser quality output than I'm sure you want to achieve. The two handed weapon movement may not be a common animation, but it will not look right if not animated correctly for the actual locomotion.

    Keep up the great work and feedback Nanako. I enjoy reading this thread.
     
    Nanako likes this.
  8. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    You need the original FBX. You can set a mask when importing it, on the Animations tab.

    Like @theANMATOR2b writes, there are some cases when it just doesn't look right to mix certain upper body and lower body animations. But you can still get a lot of reuse out of animations. Once you get the whole hammer set looking good, you could apply it to other similar weapons such as axes and clubs.
     
    theANMATOR2b likes this.
  9. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    How do you crossfade to a sub-state machine? Do you have a common entry node instead of the new Unity 5 entry that you fade to? Does that introduce any pauses in your animations? I don't think you would get any blending transitions (since it goes from node, to empty node, and then splits to whatever) but it would work.
     
    Last edited: Mar 24, 2015
  10. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Do you not crossfade into a specific state in the sub-state machine?