waves of zombies in the l4d style

Hello guys, I’m new in all this ue4 and first of all I apologize for my bad English.
I wanted to know how I could implement waves of zombies in the l4d style
I know the quick answer is to implement spawns in different areas of the map, but I see these problems …

  1. they would always appear in the same place
  2. the player could see them literally appear
    taking into account that the player would be moving around the map, how do I generate these waves of zombies near the player and that is not visible to him?
  1. Randomise their location at spawn time; have several spawners distributed manually in the nooks and crannies the player can’t see; spawn zombies behind doors or windows that swing open and spew the dead out, rooftops, vents, grates

  2. as above or spawn them behind the player / behind an obstacle they’re looking at / distract the player with light / colour / sound so they turn away

For performance reasons you should also check out the new Animation Sharing Plugin which was released with 4.22. Check the documentation here:

okay, suppose I have several spawns hidden around the map, how do I only activate the spawns that are close to the player? because if they were all activated it would be bad for the performance and the spawns more distant would take to reach the player

This would depend on how you envisioned the gameplay mechanic. Spawners can be on a timer and release just a handful of enemies to keep the player occupied. You can place trigger boxes in choke points the player has to pass through, activating connected spawners - that’s the most common method.

Proximity based approach is fairly easy to achieve, too - for something simple and reliable you can check with a sphere overlap whether there any spawners nearby and activate the ones that are are close enough to the player (check if the length of v1 - v2 is less than desired value).

Full disclosure - never made a zombie game but that’s the approach I’d try first!

You should also consider Object Pooling, because instancing so many actors at once during gameplay could result in noticable frame drops. By Object Pooling I mean something like this:

thank you very much guys, I will keep it in mind when starting the project

Interesting, is there a way to make such system with blueprints?

Yes, it’s a generic concept applicable to everything. Spawning an actor is very expensive. Instead spawn 200 projectiles at the beginning of the game or during load; keep them in an array, hidden and ready.

When you need a projectile, fetch one that is readily available; rather than destroying projectiles, flag them and move them back to the pool. Recycle what you have, you can make the pool dynamic - extend and trim it as need to. You trade a larger memory footprint (more actors spawned) for better performance (they’re already spawned!).

It does come with cons - if looking up and moving objects is more expensive than constructing them… then pooling is not helping much.

Thank you very much for these explanations :wink: I understand better the concept now, i think I will need it !

I finally need to hide pawns now but I’m not sure of the proper way of “pooling” them. Don’t know if pooling is the appropriate term, for this case they are all spawned on begin play but never be respawned once dead, the game ends when they are all dead.

I have flying pawns (fishes) which consumme a bit of fps (average 1.6 fps/pawn) and they are concentrated by flocks on the map. I can’t put a lot of them in a single visible flock due to their performance, but the problem is that invisible pawns consume ressources as well.

What I’ve done is set a culling distance for the skeletal mesh, and on a timer (2 seconds) each pawn checks if this distance is reached, if so they call unpossess on their controller, set animBP to none and disable tick. This is first call on begin play :

With 0 pawn, the average fps is 85-90, but with 50 in the same flock (and no other on the map) it decreases down to 10 fps. When all are culled it goes up to 30-35 which means that they still consumme a lot (this prevent me for placing other flocks on the map). I’ve noticed that unpossessed controllers continue to run the behavior tree, but I’ve tried to destoy them and it makes no difference on the fps (and I don’t known how to respawn them anyway), tried also to set the animation mode, no differences.

So my question would be : how can I make a distant and invisible pawn not consumme anything (or almost nothing)?
All I’ve found on google is to unpossess and set anim bp to none but apparently it is not enough.

PS: I don’t plan to have so much pawn on a flock for the moment, 5-15 would be enough, but I’d like to have several flocks on the map. I’ll wait 4.23 to see if automatic mesh instancing can help with skeletal mesh performance, or maybe consider to do vertex anim and instanced static meshes (but then the problem for me will be pathfinding, and vertex anim of course:o)