# Problem with an animation transition

I'm working with a 3D avatar and it's my first time working with animations. I have already done one which goes from the idle animation to another animation. It does the transition when the value of a slidebar is below 40, here is the code:

 Animator anim;
public Slider barraAlimento;
void Start()
{
anim = GetComponent<Animator>();
}
void Update()
{
if (barraAlimento.value <= 40)
{
anim.SetBool("IrHambriento", true);
}
else
{
anim.SetBool("IrHambriento", false);
}
}


This works correctly, but my problem is that now I want to do another transition. When I click a button, the value of the slidebar increases (that's how is triggered the previous animation), so I want a transition between the previous animation and the new one when the button is pressed. I have tried this, but it doesn't work:

Animator anim;
public Button botonManzana;
void Start()
{
anim = GetComponent<Animator>();