- Home /
How to do an animation transition
I'm using a 3D avatar made using Blender and it has two animations: the idle animation and another one. I want to trigger the second animation when the value of a slider is below a number, and go back to the idle animation when the value of the slider is above that number.
I have assigned an animator to the avatar, and I have created a trigger to use it in the transition.
I have written this code, but when the program starts, it doesn't start with the idle animation (although the slider begins with value 100 and decreases over time).
Animator anim;
public Slider barraDiversion;
void Start()
{
anim = GetComponent<Animator>();
}
void Update()
{
if (barraDiversion.value <= 50)
{
anim.SetTrigger("IrAburrido");
}
}
Answer by I_Am_Err00r · Jul 11, 2019 at 04:09 PM
In the Animator window, you can set the default animation there to Idle.
I would also change this line:
anim.SetTrigger("IrAburrido");
to this:
anim.SetBool("IrAburrido", true);
Maybe I use them wrong, but I have had a ton of trouble with SetTrigger in the animator and have much more control and success with bools.
$$anonymous$$mm, it's not working yet. I don't know what it's missing.
like @$$anonymous$$akkapylly said, make sure in the Animator Window, under parameters you create a bool named "IrAburrido".
Honestly, it's worth investing a couple hours maybe learning Unity's $$anonymous$$ecanim Tool, there are tons of tutorials on YouTube, here is one I probably have seen in the past: https://www.youtube.com/watch?v=hkaysu1Z-N8
This one looks like it's more geared towards setting up the parameters: https://www.youtube.com/watch?v=5oz$$anonymous$$p5qC4aA
Answer by Kakkapylly · Jul 11, 2019 at 06:49 PM
Did you set up the bool in Animator, with the arrow things
Yes, I have created the bool variable and assigned it to the transition from Idle to Aburrido (the other animation)
I know you probably don't want to hear this, but you might need a further grasp on how Unity's animator works. It is quite tricky, and because it's not code, it's hard to walk you through step by step in a forum like this.
Yeah I know, the problem is that I need to do it as soon as possible, so I'm going to look for all the possible information.
Your answer
![](https://koobas.hobune.stream/wayback/20220612204726im_/https://answers.unity.com/themes/thub/images/avi.jpg)