I’ve been on an optimization kick lately and I’ve gotten my game to the point where I can have 500 enemies on screen at once with all their meshes and healthbars as one draw call but what slows me down is PreLateUpdate.DirectorUpdateAnimationBegin and End as every single enemy is animated and has animations for things like stun, death, revive, etc.
It’s at the point where under load the animation system takes up more frame time than everything else in the game combined so I’m wondering if there’s any way to speed it up.
For reference with 500 enemies on screen I’m at 200 draw calls, less than 1M tris/verts, about 5ms spent in Camera.Render, less than 1ms spent in the AI, and 10ms spent in PreLateUpdate.DirectorUpdateAnimationBegin.
Yep, I’ve hit the same bottleneck. Since I’m working with sprites I’m strongly considering either rolling my own animator or maybe giving the new ‘Playables’ API a whirl. Hopefully the latter case will allow me to reuse my current animator controllers more easily.
It sounds like your animations are already pretty simple if you’ve got that many enemies on the screen but if you’re using any kind of layer blending that would probably be the first place to look. There’s not much you can do at this point. Mechanim just wasn’t designed for this kind of stuff. It was designed more for smoothly blending animations of maybe a couple dozen characters.
Also, another gotcha I learned, using mechanim and AnimatorBehaviours as an FSM for AI really sucks too. The performance for for that was even worse than the animations!