Transition parameter not changing

void FixedUpdate() {

    if(Input.GetKey(left))
    {
        gameObject.GetComponent<Rigidbody2D>().velocity = Vector2.left * speed;
        transform.localScale = new Vector2(-8, 8);
        gary.SetInteger("Is walking", 1);
        

    }

    if(Input.GetKey(right))
    {
        gameObject.GetComponent<Rigidbody2D>().velocity = Vector2.right * speed;
        transform.localScale = new Vector2(8, 8);
        gary.SetInteger("Is walking", 1);
    }
    else
    {
        gary.SetInteger("Is walking", 0);
    }

when the player pushes left or right its supposed to move them in that direction and
play the walking animation VIA setting the transition parameter for idle to walk to 1. But for some reason the parameter only changes when the right button is pressed, i tried adding in a 3rd option that turned the parameter on when the player hit space, and placed it below the second if statement, and then for some reason the second if statement wouldent change the parameter and only the third one would.

So is this a bug or am i doing it wrong, can you not have multiple if statements that change an animation parameter?

It’s not about changing the animation parameters. The problem lies with your if conditions.

For example, what happens if I press both the Right and Left keys at the same time? Your script will then try to transition to going left first but then instantly go to right instead.

If I only press the Left key, your script will try to transition to left but look you have an Else statement underneath that makes the your player not walk.

So in order to fix this:

if (Input.GetKey(left)){
}
else if(Input.GetKey(right){
}
else{
}

Now, I don’t know how you set up the transitions for your animation so you’ll have to figure out the rest when you implement jumping and idling and such.