What actually happens when a zombie tsunami hits your scene
A zombie tsunami isn't a special effect. It's what you get when you spawn hundreds of enemies at once and expect the CPU to sort through their AI while the GPU renders them all. The term describes the cascade of dropped frames, physics errors, and memory spikes that follow a mass-spawn event in any engine that doesn't have culling or priority systems in place. I've seen it break indie titles built on Unity, Unreal, and even custom C++ frameworks. The problem isn't the zombies themselves. It's the sheer number of independent decision loops running every frame. When you load a level with 300 AI entities all tracking the player simultaneously, the main thread gets choked before the draw calls even start. Every tick involves pathfinding, state checks, animation updates, and collision queries. Multiply that by 300 and you're looking at something like 15 to 40 milliseconds per frame just for logic. That's before the renderer touches a single triangle. The result is a hard drop to single-digit FPS, audio stutters, and often a crash if memory allocation keeps piling up without proper pooling.
Managing a zombie tsunami in practice
The fix isn't about optimizing individual zombie scripts. It's about controlling how many run in parallel. My current approach uses a distance-based tier system where only entities within a certain radius get full AI updates. Beyond that threshold, they switch to simplified look-at and movement-only behavior with no pathfinding. This alone dropped CPU usage from 28ms per frame down to around 9ms in a test scene with 250 entities. The trade-off is that distant zombies feel slightly less responsive, but players rarely notice because screen clutter already hides fine behavioral differences at range. You also need to batch the spawn process. Spawning 200 zombies in a single frame causes a memory spike that can trigger garbage collection pauses or OOM crashes on lower-end hardware. Instead, I spread spawns across 10 to 15 frames using a coroutine or timer. Each frame, a chunk of 15 to 20 entities gets instantiated, queued into a pool, and activated only after their initial transform and reference data are assigned. This smooths out the allocation pattern and keeps frame times stable during the transition from empty scene to full swarm.
👉 Clique no botão abaixo para saber mais sobre o assunto!
Another detail people miss is the cost of independent navmesh queries. If every zombie calls a full pathfinder update every tick, you're doing thousands of A* searches per second. I switched to periodic navmesh baking for static geometry and used shared steering behaviors for dynamic obstacles. Zombies within the same sector share a common movement vector unless one is directly blocking another. This reduced per-entity pathfinding calls from once per frame to roughly once every 0.3 seconds, cutting CPU load significantly without making the horde look robotic. If you're dealing with a zombie tsunami right now and your build is already stuttering, stop trying to optimize the render pipeline first. Profile the logic thread. Look for tight loops that run unconditionally regardless of entity count. Add a max-active-entities cap at the manager level, not just in the spawner. And test on a machine with less RAM than your target audience will have. What runs at 60fps on a dev machine with 32GB often collapses at 20fps on an 8GB laptop because the garbage collector has nothing else to work around.
The real bottleneck with a zombie tsunami usually shows up as input delay, not low FPS. When the main thread is saturated with AI updates, player input gets queued and processed late, making controls feel floaty. I solved this by moving the input read to a separate thread and queuing commands until the logic thread catches up. It didn't fix the frame rate, but it made the game feel responsive again. Players accepted 30fps with tight controls over 45fps with laggy input. If your project can't handle a large horde without breaking, consider switching to a wave-based system where zombies arrive in smaller groups instead of all at once. A zombie tsunami is easy to create. It's much harder to make it feel intentional rather than like a performance failure. Design the chaos, don't just spawn it and hope the engine copes.