Search Unity

Animation Layers, Weights & SubStates - Am I using these correctly?

Discussion in 'Animation' started by ThatRobRobinson, Feb 15, 2015.

  1. ThatRobRobinson

    ThatRobRobinson

    Joined:
    Sep 20, 2014
    Posts:
    9
    Hi there!

    I try my best to not annoy people on the forums. Forgive me if this has already been clarified somewhere else.

    I've got a character set up with a functional Base Layer for locomotion.
    I've created a second layer for "Combat" animations, with 2 sub state machines. 1) HandToHand 2)StandardCombat. I'm only working with HandToHand right now.

    What I have done is set up a 2 bool toggle system. If HandToHand = True (button hold) & if Fire1 = True (left punch) then animate the mesh.

    My scripting works. I see the animator functioning as it should. My combat layer, with a weight set to 1 receives its command via script, animates correctly, BUT it disables my base layer completely, even when the toggle is false.

    Now, If I drop the weight to 0 my locomotion layer becomes functional, but the combat layer, while still receiving information from my script, doesn't override the base layer (obviously). I have tried lowering the weight on the combat layer to .5 and .25, but I just get an additive sort of result, despite the animation layer being set to override.

    I do not seem to be able to change the weight of the base layer in the editor.

    My instinct tells me I have to do something else in my script to have the animator automate weight changes based on events.

    Advice? :)
     
    Last edited: Feb 15, 2015
  2. ThatRobRobinson

    ThatRobRobinson

    Joined:
    Sep 20, 2014
    Posts:
    9
    Nevermind. Im an idiot. Solved it with SetLayerWeight(1,1)

    Code (CSharp):
    1. void HandToHandManagement (bool HandToHand, bool Fire1)
    2.     {
    3.         if (Input.GetButtonDown ("HandToHand"))
    4.         {
    5.             anim.SetBool(HandToHandBool, true);
    6.             anim.SetLayerWeight(1,1);
    7.         }
    8.         if (Input.GetButtonDown ("Fire1"))
    9.         {
    10.         anim.SetBool(Fire1Bool, true);
    11.         }
    12.    
    13.        
    14.     }
     
    theANMATOR2b likes this.