Double key combination problem

So here is my problem. I’m writing an animator controller and I’m trying to use a combination of two keys for sprinting animation. Thing is they work only one way, for example if I press W and then LeftShift, everything is just peachy, but when I do the presssing in a reversed order, it just doesn’t work. Here’s the code:

 if (Input.GetKey (KeyCode.LeftShift)) {
    				if (Input.GetKey (KeyCode.W)) {
    					anim.SetBool ("isWalking", true);
    					anim.SetBool ("IsRunning", true);
    					Debug.Log ("isWalking = true");
    					Debug.Log ("IsRunning = true");
    				} else {
    					anim.SetBool ("isWalking", false);
    					anim.SetBool ("IsRunning", false);
    					Debug.Log ("isWalking = false");
    					Debug.Log ("IsRunning = false");
    				}
    } else {
    				if (Input.GetKey (KeyCode.W)) {
    					anim.SetBool ("isWalking", true);
    					anim.SetBool ("IsRunning", false);
    					Debug.Log ("isWalking = true");
    					Debug.Log ("IsRunning = false");
    				} else {
    					anim.SetBool ("isWalking", false);
    					anim.SetBool ("IsRunning", false);
    					Debug.Log ("isWalking = false");
    					Debug.Log ("IsRunning = false");
    				}
    
    }

I know that the code is rather long and one if clause would do the trick because I already tried that. But I had the same problem back then and I thought that maybe it’s a compilator issue with the order of conditions inside the if clause. That’s why I arrived with this solution that doesn’t help either. On a side note, I have the animator set up the way that you need both isWalking and isRunning conditions to be true to get the running animation.

So an example of how this works upon testing: I press down W, the character walks, while still pressing W i press down the LEFT SHIFT key, the character runs. I let go of the LEFT SHIFT key, character walks again, I press LEFT SHIFT again, the character runs again. But when I either start with LEFT SHIFT key or let go of W while running and then press W again the animations do not play. It’s not a key issue, because I tried using different keys instead of LEFT SHIFT. Funny thing is, I get the Debug.Log (“isWalking = true”) and Debug.Log (“IsRunning = true”) inside the console. Any suggestions?

Yeah, it turned out that I messed up transitions from idle to running, that’s why idle to walking was working, and walking to running was ok too. THX for your help.

//Pseudo code, maybe it can help!

if (Input.GetKey (KeyCode.LeftShift) && Input.GetKey (KeyCode.W)) 
{
   if(anim.SetBool ("isWalking") == false && anim.SetBool ("isRunning") == false)
   {
         anim.SetBool ("isWalking", true);
         anim.SetBool ("isRunning", true);
   }
    else 
  {

 anim.SetBool ("isWalking", false);
         anim.SetBool ("isRunning", false);  
   }
}
else
{
     if (Input.GetKey (KeyCode.W)) 
                     {
                         anim.SetBool ("isWalking", true);
                         anim.SetBool ("IsRunning", false);

                     } 
                   else 
                       {
                         anim.SetBool ("isWalking", false);
                         anim.SetBool ("IsRunning", false);
                     }

}
}