Search Unity

Mecanim sync layer

Discussion in 'Animation' started by mr malee, Aug 29, 2013.

  1. mr malee

    mr malee

    Joined:
    Sep 19, 2012
    Posts:
    25
    Hi, I'm having a little trouble trying to understand how Sync Layer works in Mecanim.

    From the Docs it looks like you can have a base layer which contains machines/states/blend trees and then replace the animations on your new layer with different versions.

    Official docs: "Sometimes it is useful to be able to re-use the same state machine in different layers. For example iyou want to simulate "wounded" behavior, and have "wounded" animations for walk / run / jump insteadof the "healthy" ones. You can click the Sync checkbox on one of your layers, and then select the layer youwant to sync with. The state machine structure will then be the same, but the actual animation clips used by the states will be distinct."

    • Now I've got my base layer all setup with my states, sub machines and blends.
    • I've got another layer above it called "Arms" which is responsible for the aiming of a weapon.
    • I would like to sync the base layer to the arms layer and replace the base layer animations with weapon aiming animations.

    However, after I click sync, I see the base layer states copied across, but when I double click they're empty.

    Also, it looks like I'm always in the BaseLayer in the Animator Window! I keep trying to select the "Arms" layer, but the layer name at the top of the window always says "Base Layer".

    I'm just not sure how to use this whole Sync system and it's workflow is not apparent to me. The docs state that the entire state machine will be copied across. Well, no, the names get copied, but the internal blend trees and sub machines are empty. After pressing the Sync layer checkbox, it seems after select that layer I'm in a weird state where I'm half between the base layer and my Arms layer, very confusing.

    Anybody know any tutorials that explain this system better than the official docs?
     
    dreasgrech likes this.
  2. ShadowOfTheBeast

    ShadowOfTheBeast

    Joined:
    Apr 8, 2013
    Posts:
    13
    try looking at the mechnim tutorial 4.0 it might help

    http://video.unity3d.com/video/7362044/unity-40-mecanim-animation-tutorial

    ...I am currently trying some thin like that as well....I don't know if you have seen the masking as well when you create a sub layer you have to mask the base layer animation of your character its avatar...at around 40mins into the video near the end you will see this base layer to the Layer2 section..
     
  3. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    When syncing a new layer, the Animator Controller editor treats blend trees like individual animation clips -- the blend trees are empty just like the individual clip nodes. I feel your pain there; it's a nuisance to have to rebuild the blend trees for each sync layer. I'm not sure why your sub-state machines are empty, though.

    From your description, it sounds you're trying to sync a full/lower body layer with an upper body layer. I'm not sure how well that will work out for you. Maybe this is why sub-state machines are coming empty, too.

    I use sync layers for different weapons. All the synced layers in a set of synced layers work on the same body parts (i.e., the same mask).

    For example, in a shooter, I have a set of layers for the lower body: base lower layer, pistol lower layer, rifle lower layer, etc. These synced layers all implement the same lower body state machine (walk, run, jump, etc.), with different animations for walk/run/jump/etc. When the pistol is armed, the pistol lower layer's weight is 1 and the other lower layers' weights are 0.

    I have an additional, separate set of layers for the arms: base arm layer, pistol arm layer, rifle arm layer, etc. These synced layers all implement the same upper body state machine (aim, fire, reload, etc.), with different animations, masked to work on the arms only. When the pistol is armed, the pistol arm layer's weight is 1 and the others are 0.

    I hope some of that up there is helpful. Also, when changing weapons, I lerp weights between the old weapon's layer and the new weapon's layer to give a smooth transition. Over a short time period, the old layer's weight goes to 0 and the new layer goes to 1. The base layer is always 0.
     
  4. dreasgrech

    dreasgrech

    Joined:
    Feb 9, 2013
    Posts:
    205
    I'm also having the issue where blend trees in synced layers have no blend tree attached to them (shows as "None" in the Motion field).

    I understand that it works for normal states where you can drag in a new animation in the synced state but how can you modify the blend tree in the synced layer?
     
    atalantus likes this.
  5. SiriAnimates

    SiriAnimates

    Joined:
    Jun 30, 2020
    Posts:
    1
    I know I'm a bit late, but do you know how to replicate blend trees. I tried creating a new one, but it applied to the base layer as well. I'm trying to add different armours as well on top of a base player, but I'm stuck on whether it is override, additive and weights. Thanks
     
  6. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    You need to create it from scratch as I mentioned above in 2013.