Something is wrong with my animation in Unity,

I’m trying to do an animation in unity,
Changing it with script,
and when i Jump and then press the arrow key it is fine, but if i jump while holding the arrow key it switches between the jump and the walking,

here is my code:

if (dirX != 0 && GameManager.instance.grounded)
{
anim.SetBool(“walking”, false);
anim.SetBool(“jump”, false);
//Debug.Log(“grounded”);
}
else if (GameManager.instance.grounded && dirX == 0)
{
anim.SetBool(“walking”, true);
//Debug.Log(“Walking”);
}
else if (!GameManager.instance.grounded)
{
anim.SetBool(“jump”, true);
//Debug.Log(“Jumping”);
}

what is wrong here?

Hey mate, just noticed that you might have your booleans wrong, while reading your code i can see that you have when dirX != 0 you walking is set to false. which should be true. and the other way around in your Else if

The problem is likely on how the Animation Transition is set up, do you have Exit time enabled? It should be disabled if you’re using parameters. Enabling Exit time makes it automatically trigger the transition regardless of parameters.