- Home /
Syncronise animation of instantiated objects
I'm making a 2D musical exploration game. There is a bit where there is a crowd of creatures moving in time with the music. I instantiate them randomly to create the crowd, but now their animations are all out of sync, since they are instantiated ad different times. How can I make sure the animations are all moving in sync? Thanks
Answer by Baroque · Feb 25, 2014 at 08:16 AM
Probably the easiest way is to start the animations over on every beat (or bar, or phrase, or whatever you're syncing the animations to). Since you know when the music started and its beats-per-minute, you can calculate the number of the current beat by:
beat = audioSource.time / (bpm * 60)
Every time this goes up by a whole number, start the animations over. You could pass that as an event into MecAnim (or your animation code).
If you want to sync every 4 beats, just divide by 4.
that sounds like it would work, i'll give it a go. Thank you!
Your answer
Follow this Question
Related Questions
How do I sync the animation of objects instantiated at different times? 0 Answers
2D Animation does not start 1 Answer
Animation in Unity editor prevents rotation in script 1 Answer
Using Animator animation, how to do an animation or start code when an animation finishes? 2 Answers
How to optimize 2D Animations created with 2D Animation packege? (v3.1.1) 0 Answers