Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Mecanim Layers not working

Discussion in 'Editor & General Support' started by Lazer_13, Dec 4, 2012.

  1. Lazer_13

    Lazer_13

    Joined:
    Oct 24, 2012
    Posts:
    9
    Hi,

    I have been trying to override the animations on the legs of my character using animation layers, but the animation from the base layer runs even though the second layer is working perfectly.

    I have searched for an answer to no avail, are there any common mistakes associated with this?

    Thanks
     
  2. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,171
    Are you using the Pro Version, and are you referring to Synced Layers? If you are not using Pro, and are referring to Sync Layers (the abilitly to share StateMachines between multiple Layers), that is a pro-only feature. Otherwise, I have no help, sorry.
     
  3. Lazer_13

    Lazer_13

    Joined:
    Oct 24, 2012
    Posts:
    9
    sorry, i'm not referring to any Pro features such as sync or curves. I have added a second Layer (after the base layer) with a body mask of only the legs. The stae machine in that layer works as I want, but the animation does not override the base layer.

    Thanks for trying :)
     
    Last edited: Dec 4, 2012
  4. Lazer_13

    Lazer_13

    Joined:
    Oct 24, 2012
    Posts:
    9
    For anybody who gets stuck with this problem, LayerWeight is set to 0 as a default. Make sure you use animator.SetLayerWeight() in your scripting.
     
    myxolobe, Maltesj and DotusX like this.
  5. Turtlemaster

    Turtlemaster

    Joined:
    Aug 7, 2012
    Posts:
    9
    Lazer, thanks for posting the solution once you found it. ^__^
     
  6. Brodal

    Brodal

    Joined:
    Jan 26, 2013
    Posts:
    8
    Yes, thank you for posting the solution! Just saved me quite alot of time.
     
  7. Asvaronn

    Asvaronn

    Joined:
    Dec 30, 2012
    Posts:
    1
    Saved my time too, thank you =) as mecanim does so much automatically I didn't even start to think about setting layerweight by script.
     
  8. jimmay

    jimmay

    Joined:
    Sep 23, 2010
    Posts:
    28
    Another thanks for helping me solve this issue. Seems silly to allow layers and then default them to off. Yes, I want to add layers and not use them.
     
  9. Julien-Lynge

    Julien-Lynge

    Joined:
    Nov 5, 2010
    Posts:
    142
    Indeed - it is quite annoying. They mentioned toward the end of last year that 'soon' we would be able to set the layer weights directly in the GUI. Obviously that hasn't happened yet :)
     
  10. Peter Hou

    Peter Hou

    Joined:
    Oct 12, 2010
    Posts:
    66
    I was struggling with this as well. Thanks for the solution, Lazer_13 :)
     
  11. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    926
    They should really fix this..
     
  12. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    Thanks so much! This saved me a lot of time. I fiddled around for about 15-30 minutes. I then look on the forum, and here it is. The layer weight should be set to 1 by default...
     
  13. t1000

    t1000

    Joined:
    Jan 30, 2016
    Posts:
    16
    Hi there,

    Still having this issue: my upperbody mask has only arms selected, etc. However, once I play the full body applies the animation. If I change from Override to Adaptive, it works but the animation has unexpected behaviors.

    In the code I have setup that when you press a key the LayerWeight is set to 1f for layer 1.

    pAnimator.SetLayerWeight (1, 1f); BaseLayer has weight 1 in the editor by default, and you cannot change that.
     
  14. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    You may be able to manually set it in the Mecanim Editor? This usually works if you don't need to change the layer weight through scriptiong.
     
  15. Willzone89

    Willzone89

    Joined:
    Feb 23, 2016
    Posts:
    1
    Maybe this can help you:
    I had same same problem because I made a mistake on dragging the Idle animation to "Nothing" state producing unexpected behaviors. The "Nothing" does not have to be set with any motion.
     
  16. Tymianek

    Tymianek

    Joined:
    May 16, 2015
    Posts:
    94
    Turns out when you create new layers the weight is set to zero. If you click the gear icon in the layers, you can set the Weight value to one there.
    upload_2019-10-27_21-3-26.png
     
  17. Maltesj

    Maltesj

    Joined:
    Feb 7, 2020
    Posts:
    11
    This post still saves time in 2020. Thanks.