How can I create COD Zombies type spawning?

I am creating a survival shooter game in which enemies are spawned similarly to how zombies are spawned in COD Zombies. I have created a single spawner which spawns waves of enemies, but what I want to do is create multiple spawners to be able to be placed around the map and have those spawners only spawn enemies when the player is in a certain vicinity of them. It is going to be a fairly large map, and it wouldn’t make sense for every spawner on the map to be spawning enemies if the player isn’t close to them (ie. player on one side of the map, spawner on the opposite side spawning enemies). How do I create a system which allows a certain number of enemies to be spawned each wave like I have already, but also distribute the enemies being spawned to whatever spawners the player is near?

A high level overview of how I would set something like this up is have some kind of MasterSpawnManager which stores references to all of the individual spawners in the level, and then that holds information like how many zombies to spawn, how many have spawned, etc (Depending on your game structure, you can do this all in the gamestate as well, which is where I’d probably put it).

The second part of this is knowing if the player is close to a spawner. One way you could do this is setup a collision volume around a spawner which overlaps with the player character, and when the character overlaps this volume, the spawner becomes “active”, and when the player leaves, it becomes inactive. When it is time to spawn zombies, the MasterSpawnManager goes through all of it’s spawners, gets the active ones, and then disperses the spawns between them however you want that to be setup.

I hope this helps!

-Testy

Since there a ton of ways to do this, this is more of a design question than a technical one. I’ll give you one method, but don’t take it as the only/best one.

I would probably use 2 things; a Game State blueprint (GSBP) and a Zombie Spawn blueprint (ZSBP).

  • Use the GSBP to keep track of when to spawn zombies and how many to spawn.

  • I would add a large trigger box component (TBC) to the ZSBP.

  • Using overlap in/out events along with the TBCs in the ZSBP, I would store some bool variable that is True when there is a player close enough to the spawn point.

  • Assuming the number of spawn points don’t change during gameplay, in the GSBP, on Begin Play I would Get All Actors of ZSBP class and store their references in an array variable.

  • When the GSBP decides it’s time to spawn zombies, it loops through this array asking if there is player nearby. If there is, call the spawn event on the ZSBP and track the number of enemies in the GSBP.

  • If the player is not near any spawn long enough to spawn all the enemies, the end of the loop triggers a timer that calls the loops again every 1 second.

All of this is maybe a touch overkill to just achieve what you want, but it allows an easy way for more complex logic to be built on top of it.

This is pretty much what I said. I didn’t mean to steal your answer, you just typed it faster than i did. :wink:

Haha no worries! Yours is more detailed so it is probably more helpful!

Thank you for the idea and great blueprint examples. However, I’m not exactly there yet. First, is there any way in which I can distribute the amount of enemies spawning to the amount of the spawners the player is near (ie the wave needs to spawn 15 enemies, the player is standing near 3 spawners, so each spawner spawns 5 enemies). Also, on your event begin play, I do not understand how you got all actors of class then communicated with the enemy spawns. Is there a certain integer type I need to use to make this happen? I’m confused.

Here’s the spawning system I’ve made so far. It all occurs in the same blueprint because I’ve only created a single spawning system. Maybe these pictures will help give you an idea of what I’m working with.

I’ve added pictures so you can see what I have so far.

In regards to your question above:

The game state BP I showed you is already doing that, distributing spawn commands through all of the spawn locations the player is close to until the “active enemies” int = the “enemies needed” int.

I got all actors of enemy spawn class by using the node “Get all actors of class” and putting them in an array. You need to loop through this array and cast to your enemy spawn BP in order to call events or functions in it.

You’ll need to be familiar with casting, it’s pretty important for communicating between BPs. Here’s a resource for communicating between blueprints that covers casting a little bit, but also has a lot on other forms of communicating between blueprints as well:

*NOTE* - I am not actually tracking how many enemies are still alive in my BPs above, nor did I implement any logic to check for when to call the next wave. This is kinda outside of the scope of this question. If you have a specific question about those things, let me know.

In regards to your pictures, I don’t want to tell you how to specifically rearrange your BPs because it will probably take too long and I’d have to explain too much if you’re not familiar with communicating between blueprints. I can only answer more specific questions.