How to play many animations at once without slowdown?

Hi everyone,
I’m working on porting a game to Unity. As part of the original game, there are times when 100 animations play all at once. I have imported all of those assets into my game and have created code to play all of those animations at once. I basically run through a loop and play a different one on each iteration. Now, this actually works, but the first few times I go through the loop, there is about a second of lag. After 2 or 3 tries, it happens with no lag from there on out. I’m guessing because the animations are cached at that point.

  1. Is there a better way to do this that I don’t know about? Like I said, I am going through a loop, but maybe there is a better way?

  2. Is there a way to force those animations into cache without playing them all?

Thanks everyone ahead of time!

I assume you use animator. If you do not, then you really should switch to it. Another thing is that for all of the rigged 3d models you should check “Optimize GameObjects” box in the inspector. This allows animator be multi-threaded, it also removes all the transforms you do not need and puts mesh skinning on the GPU. For more information check out this talk.

For another question I believe unity loads all the data once you set the structure up (spawn the game object).

This is probably because Unity is loading all of those animations, after they load you can play them without issues.

The best way is to just do it at the start of the game (in a loading screen).

Going back to part (1) of my initial question, is there a better way to run a ton of animations on duplicate gameobjects by looping through them all and essentially saying "animator.Play(“animationName”). It definitely taxes the CPU here…