Can't de-activate a bool [Mecanim]

Hello, I am trying the new mecanim system. I am using the basic tutorial and trying to modify it. What I want to achieve is that, when I press the left shift, the character starts to run.

So I set up the “LShift” key in the input manager (with the “Positive button” set on “left shift”).

Then I set up a “Base Layer.Walk” (with Walk, WalkRight, WalkLeft), a “Base Layer.Run” (with Run, RunRight, RunLeft) and a “Base Layer.Jump”.

Other than Speed and Direction I set up two booleans: Jump and Run. My animator is: [IDLE] – (speed greater than 0.1) → [WALK] – (run is true) → [RUN] – (jump is true) → [JUMP]

My code is:

            // RUN CONTROL
		
		if (currentBaseState.nameHash == walkState)
		{
			if(Input.GetButton("LShift"))
			{
				anim.SetBool ("Run", true);
			}
			
			else
			{
				anim.SetBool ("Run", false);
			}
		}
		
		// STANDARD JUMPING

		if (currentBaseState.nameHash == runState)
		{
			if(Input.GetButtonDown("Jump"))
			{
				anim.SetBool("Jump", true);
			}
		}

(etc.)

But it seems that the “RUN” bool never deactivates. Anyone knows why this is happening? Did I miss something? Thank you.

What about trying this :

 if (currentBaseState.nameHash == walkState)
           {
             if(Input.GetButtonDown("LShift"))
             {
              anim.SetBool ("Run", true);
              currentBaseState.nameHash = runState
             }
    else{
    currentBaseState.nameHash = walkState;
           }

Not sure if it’s right though.
I would youse boolean variables and animation.CrossFade to change the Animation though.

I managed to get it to work.

New code:

if(currentBaseState.nameHash == walkState)
    {
      if(Input.GetButton("LShift"))
         {
           anim.SetBool ("Run", true);
           Debug.Log("I'm running!");
         }
    }

if(currentBaseState.nameHash == runState)
    {
      if(Input.GetButton("LShift") == false)
    	 {
    	   anim.SetBool ("Run", false);
    	   Debug.Log("I'm not running!");
    	 }
    }

It also fixed a bug where, if I press LShift for <0.5 sec, the bool stays active. Now it works perfectly. Thank you.

I found some problems when referencing by tag , try to use a reference from a public animator variable filled by drag and drop