x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

Product Version: UE 4.19
Tags:
more ▼

asked Oct 30 '18 at 04:26 AM in Blueprint Scripting

avatar image

cashnastymike
1 1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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

more ▼

answered Oct 30 '18 at 05:19 AM

avatar image

TestyRabbit
351 7 6 13

avatar image PixelOmen Oct 30 '18 at 07:17 AM

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

avatar image TestyRabbit Oct 30 '18 at 03:22 PM

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

avatar image cashnastymike Oct 31 '18 at 02:06 AM

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.

avatar image cashnastymike Oct 31 '18 at 02:35 AM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

alt text alt text

gamestate-bp.jpg (423.7 kB)
enemyspawn-bp.jpg (365.1 kB)
more ▼

answered Oct 30 '18 at 07:13 AM

avatar image

PixelOmen
617 21 15 35

avatar image cashnastymike Oct 31 '18 at 02:35 AM

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.

snip-1.png (152.5 kB)
snip2.png (199.0 kB)
avatar image PixelOmen Oct 31 '18 at 04:38 AM

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:

https://www.youtube.com/watch?v=EM_HYqQdToE

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question