Search Unity

Animation blending between 2 layers

Discussion in 'Animation' started by BenouKat, Mar 22, 2018.

  1. BenouKat

    BenouKat

    Joined:
    Feb 29, 2012
    Posts:
    222
    Hello Unity devs !

    Here's the case : I have 2 layer in my animator : One for the walk/running animation (Layer 1), that animate all the body, the second one for only the hands (Layer 2, override mode).

    So if the override blending in Unity works as intended : If the transform is not controled in Layer 2, Layer 1 takes the control. I understand that.

    To sum up the case :
    - Layer 1 animated constantly both right and left hand
    Layer 2 :
    - Empty state : No animation
    - Equiped state : Animation only on the right hand
    - Aim state : Animation on both hand

    Transition between Empty and Equiped => Okay, the left hand just keep its position/rotation define in the current running Layer 1 animation. Works well in both ways.

    Transition between Empty and Aim state => Okay, the left hand blend well between its Layer 1 animation and the Layer 2 "Aim" animation. Works well in both ways.

    Transition between Equiped and Aim state => Failed. The left hand is blending with its "default" position, and then clip instantly with it's Layer 1 animation when the transition is over. This is very weird.

    Question : Is this a bug or it is intended ? How can I blend the left hand correctly in the third case ? Do I miss something in the understand of blending with 2 Animator Layer ?

    Thanks a lot !
     
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    What are the conditions for the transitions in layer 2 ? And your layer masks are set correctly for both hands?

    I think your understanding is correct - but since this is an override layer - I would animate both hands in all states - because I don't trust override layers. :D

    I don' think this is a bug - override layers are particular sometimes - I'm sure there is something happening either with the condition and/or the transition that is not registering correctly.
    Might need two override layers (one for each hand with proper layer mask), but I don't think this is a 'fix' to the problem - just a work around.

    Since the layer mask is for all states (right?) when transitioning from equip to aim the layer is keeping the base animation association with the left hand.
    Can you put a check debug.log in your code to register when the override happens on the left hand when transitioning from equip to aim - OR when the condition is met to transition from equip to aim?
     
  3. BenouKat

    BenouKat

    Joined:
    Feb 29, 2012
    Posts:
    222
    Hi ! Sorry for the delay !

    Thank you for the reply, you were right : It's just a layer problem. I made a third layer with my Equiped state (and an empty state), and it works like a charm.
    So maybe it's "just a workaround" but it works well actually.

    I didn't really understand in your answer what I have to debug in the Debug.Log to be honest :eek: But you lead me in the right solution ! Thanks ! :)

    PS : What do you call "Layer mask", is that just the Layers? Because there's also "Avatar mask" but it's for humanoid, which is not my case here. I mean I know what "Layer Mask" is in Unity (for physics, camera, etc...), but the "LayerMask" in Unity and the "Layers" in animator aren't linked at all, are they ?
     
  4. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Apologies - yes - I've been in 3D Max for a couple weeks, and I use the term Layer mask in place of an avatar maask applied to a specific animation layer.


    Glad you found a solution that fixes the issue.