Play animations simultaneously on multiple game objects with multiple animation controllers
Hi fellow Developers!
This is driving me crazy. I'm making a card game. I have many cards on the scene, each with its own animator. The animator has every state of a card. Every state (=animation) has the same length, same sample rate and every transition has the same properties. Also, all curves set to Auto, so there is no smooth start. (See animator.png below) However the cards won't move simultaneously.
I set the state of each card with the animation controller. I also ended up using coroutines in order to make sure, it's not the logic that is causing the problem. (So anyway the result is the same with just the one line that sets the state of the animator.)
// This is called on each card during the logic is calculating stuff
public IEnumerator goToState(CardState state) {
this.animationEnabled = false;
yield return new WaitUntil(() => this.animationEnabled);
this.GetComponent<Animator>().SetInteger("State", (int)state);
}
// This is called on each card ~"at once" from a foreach loop After the logic is done with time consuming stuff
public void animate() {
this.animationEnabled = true;
}
And I end up with this:
Actually in this case (because it's not always the same), two or three of the overlapping cards have started moving earlier than the others. Important note: the first time, when cards are starting to move - with the same script above - from the default state (N), they are moving simultaneously. It only happens, when all the cards are starting to move from different states.
Can you suggest me a solution to this?
Your answer
Follow this Question
Related Questions
One fbx file with multiple objects with their own animation 3 Answers
How do I know what animation I can transit to in the animator, from my current animation? 0 Answers
Why is the last frame of the animation not triggering? 0 Answers
Script animation 2d question,Script animation 2d 0 Answers
Animation won't play 0 Answers