- Home /
Can I stop all animations that are currently playing?
The question is the title, I have multiple objects with multiple animations and I need a code to stop them all at once. Not sure how to do that, would like some light on the topic, thanks.
Answer by Laiken · Dec 15, 2016 at 04:19 AM
I believe this would work:
Animator[] animatorsInTheScene = FindObjectsOfType(typeof(Animator)) as Animator[];
foreach (Animator animatorItem in animatorsInTheScene)
{
animatorItem.SetBool("IsIdle", true);
}
You need to add a condition in the Animator called IsIdle for the animators you have and have it transition from any state to the idle state of your animation
if you just want them to stop and freeze, substitute "animatorItem.SetBool("IsIdle", true);" for animatorItem.enabled = false;
Your answer
Follow this Question
Related Questions
Animator switching between floats 1 Answer
Gameobject does not leave TPose in Playmode 0 Answers
Why Animator blocking rigidbody ? 0 Answers
Hiding non-public functions from Animation Event Window? 0 Answers