Download

Multiple boxes acting as one spawner?

Hello guys, I am making a prototype FPS rogue-like game. Presently I have a single large box covering the map. This box is my spawner blueprint with all of my AI spawning logic in it. It keeps enemies on the map at a solid 20, so if some die, new ones spawn randomly within that box. I love how it works but I have 2 problems with it.

  1. Since I am using BSP brushes in a square map, I had enemies spawning inside BSP brushes. To stop that I placed blocking boxes (forgot real name now) and made sure they only spawn if a free spot is available, and to first find one if they are unable. That’s working about 90% of them time so once in a while I get a AI spawning inside my BSP :frowning: Will I have to turn everything into a static mesh to solve this?

My other solution idea instead of going static mesh, and this is part of the expanding idea that I’ll have an outside area with unlevel ground and upper areas too…one single spawner box is not going to work because they will spawn in blocks and spawn under terrain and its generally a pain in the but otherwise as you can see. I already tested this with terrain mesh generation and they fall through or spawn under raised parts of the ground.

  1. I’m sure it’s possible to have multiple spawnboxes, but all of them act as if they were 1 and the same? I can’t have each box keeping 20 enemies spawned, can someone point me in the right direction about how to achieve that? the logic should keep 20 spawned and randomly spawn them inside one of those boxes…i dont want 20 in each box. I hope this is clear

Any ideas? Thanks in advanced!

Make spawning box actor and create spawn event. Place these spawning boxes how many you want into your level.
Then create actor “main spawner”. Place 1 that actor anywhere to your level.
At begin play, in main spawner use node “get all actors of class” and save their references to array.
After delay or whatever you want, get ref to spawning boxes (array filled at start of game), get length of array minus 1, use random integer in range from 0 to length minus 1, now you got ref to one of that your spawning boxes and call event “spawn”.

The box is already a blueprint actor

Ok so I have to add more named boxes, and make another array in the main one calling to those boxes much the same way it uses an array to choose from 16 different enemy models…

the “random integer in range” you mentioned will choose a box in the array to spawn one of my enemies in from spawning code you see in this pic attached?

b2185e1fe315088dca1454b412b5cd4ce9f7cd0a.jpeg

  1. Yep, add how many boxes you want… but dont make array in their BP, in “Main spawn actor” create array and fill it on begin play, with node “get all actors of class - spawning box”, i recommend only on begin play, not on every enemy AI spawn once you creating spawning boxes in runtime…

  2. when you drag wire from array “array of spawning boxes”, type “get”, you will get one of that boxes, depends on index(int), so i think you want to randomly spawn enemies in random boxes, so use node "random integer in range) with start 0 and end of [array length] - [1]

Ok thanks 368, the only thing I am worried about is that I have different maps. Making this in the player blueprint forces me to always use the same amount of box for each level? what happens if one of the boxes listed in the array are not present in the level?

Sounds like some trial and error testing lays before me :d

Dont make it in player bp :slight_smile: you made spawning box which is ok. You can place any amount of these boxes in your levels. “Main spawning” actor which you create (and there should be logic), use one per one level. It dont have any meshes or collision, so put it anywhere in your level (e.g. under landscape or to the sky). It will start its logic on every level start.
When you use node “get all actors of class”, you can have any amount of spawning boxes in yourlevel, that node will get all boxes placed in level. With this and random integer in range with inputs as i described, it is the most dynamical logic so you can have 10 or 1000 spawning boxes in your level, it will work reliable :slight_smile:

ohhhhhh!!! That’s sweet then the “main” one acts like a controller then and I wont need the array then! Much simpler i wasn’t thinking. This is all so complicated its sometimes hard to think simple! Thank you so much for your help brainstorming this for me.

YOU da MAN!

Just for fun here is a video i shot of the game, since i just recently picked it back up after a long pause…very long indeed (eng vers. 4.9). 2 more of these videos are to follow because i’ve done a lot in one week to it!

I added that screenshot in my second post by the way

Oh hell yeah worked first try mate :smiley:

Wish I could buy you a beer tonight