Search Unity

Resolved Mixing and syncing animations... but how?

Discussion in 'Animation' started by Poi-son, Jan 9, 2022.

  1. Poi-son

    Poi-son

    Joined:
    Dec 22, 2021
    Posts:
    33
    Hi,

    First of all the heading is a bit generic so I'll try to explain my problem with as much details as possible, so please bear with me. Also, I'm new to Unity and animation so I'd welcome any explanation in layman terms :rolleyes:

    My problem with animation transitions and syncing are mainly related to kind of "sub-states" of an animation.

    By this I mean,

    *) Syncing a sheathing/swinging sword while running animation TO running-only animation.
    *) Syncing holstering or drawing a weapon or firing it while running TO running-only animation.

    same goes for idle positions and etc.

    Problem in detail,

    When my character runs, I want to give the player the ability to (at some point, with a button press etc) fire while running but at the same time keep the legs/feet run cycle/swing consistent. So, I cannot use two full body animation for such purpose.

    Actually I tried this with 2D sprite based animations and playing around with layer-weights solved the problem for that setup. I put 1 simple run animation of 24 frames on one layer and one run animation again with 24 frames (with same feet and leg poses) with hands holding a gun into another layer. Those two animations were always running on top of each other synced and I was switching layer-weights back an forth while drawing a gun but at the same time keeping the legs swing stable without jumping frames.

    But I believe Blend trees or this whole bone system has a better solution for this that I'm unaware of as yet. :oops:

    So, how do you target "some" or particular limbs during an animation that is already running and keep the rest of the animation/pose consistent at the same time? For example in the running actions example above, separating the upper and the lower body.

    I'll be glad if someone reveals the trick behind this and point me to the correct direction and setup.

    Also, I think I won't be able to use simple mecanim states and parameters for this purpose. Are the blend trees all about this? If so, are there any comprehensive tutorials on this?

    Thank you in advance!
     
  2. Poi-son

    Poi-son

    Joined:
    Dec 22, 2021
    Posts:
    33
    SOLUTION :
    For those beginners like me who tries to achieve the same thing (mixing different animations),

    Avatar masks and Layer Weights is the answer.,
    As far as I understand and successfully have tried, I created a character that compiles with humanoid rig rules. Then created an avatar mask for that character and turned off lower body parts in it.

    Then created another layer for aiming/shooting pose/animation and assigned the avatar mask on it.
    Changed the layer weight from within code upon attacking and job is done.