- Home /
How to play two different animations by one animator without stopping one of them
Hey, guys, I have a machine showing in below picture:
The machine has two parts, one is red-marked and the other is yellow-marked, each of them has an animation, and both are controlled in one Animator, and now I play one of them, say: AnimationA, and sometime later I want to also play AnimationB.
I have tried several ways, like: build two Animator Layers or make a Blend Tree, but both of them have the problem that when playing one of the them, the other animation will get less playing. Because it is not a Humanoid gameobject, I want the animation to play without any influences by the other.
Maybe I had misunderstood about the Animator Layers or the Blend Tree, if anybody can give me suggestions that will be really helpful and appreciated. Thanks.
Answer by Shadex · May 21, 2019 at 08:51 AM
Ok, so what you need to do is make an empty state called "null" and set it as default in the animator. Then right click and make a transition between null and AnimationA and then make another transition from null to AnimationB. Now click on parameters (instead of layers) and make 2 bools, animationAPlay and AnimationBPlay. now click on the transition and add the animationAPlay bool as a condition. and have it set to use true. Make another transition back from AnimationA to Null and add the bool as a condition and set it for false. Now any time you want to play the animation call:
Animator.SetBool("AnimationAPlay", True), to play the animations or Animator.SetBool("AnimationAPlay", False) to stop the animations.
Make sure the animation is set to loop, and your done.
Your answer
![](https://koobas.hobune.stream/wayback/20220612200731im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Animation Running Game 0 Answers
How can I change my AnimatorState instantly? 1 Answer
How to get reference to a specific Animation Clip in Animator. 0 Answers
2D Animation Transition Bug 0 Answers