Answer the question
In order to leave comments, you need to log in
How to enable one and disable another animation when clicking on a Button?
How to make it so that when you click on the Button, an additional animation fires, and the first one that is looped at that moment stops, and then immediately the additional animation stops, and the main one (which was initially looped) continues until the next button is pressed?
Answer the question
In order to leave comments, you need to log in
Activate and end animations in code, use coroutine to delay time
void buttonClick()
{
StartCoroutine(animationControl());
}
IEnumerator animationControl()
{
anim.SetBool("firstAnimation", false);//выключаем постоянную анимацию
anim.SetBool("secondAnimation", true);//включаем временную
yield return new WaitForSeconds(2);//укажи время проигрывания второй анимации что бы она успела проиграть
anim.SetBool("firstAnimation", true);//включаем обратно постоянную анимацию
anim.SetBool("secondAnimation", false);//выключаем временную
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question