Noob question regarding Spawning points and Locations

I’ve made a level blueprint that spawns multiple enemies (of the same type) in multiple locations (Using spawn points). The location each enemy spawns at is randomly chosen from an array of 4 points right now. My problem is that I want 1 enemy bot per randomly selected spawn location but, more often then not multiple enemy bots will spawn at the same points. What should I use to get around this?

Any help would be appreciated or any generic screenshot of what I should do.

Malibu,

Maintain two arrays, one array is like you are using now, and when you select the random point from the array, remove that point from the array it was selected from (i.e. just remove it using the index of the element). Then when the array is empty (i.e. number of elements in the array < 1), then just reload the array from the “master array”, that just holds the points and nothing more.

or,

as you remove the points from the current array, add then to the other array, and switch array pointers when one of the arrays is empty. This requires one extra variable, but is slightly faster, and somewhat easier to maintain.

Hope this helps,

Inc.

Thank you very much I will try your suggestions later and see if it helps.

Would it be possible for you to send me a print screen of your suggestion? I think your suggestion is right but I’m unsure about how to implement it.

, just put this together so you could see how it would work, modify to your hearts content!

If you do not have midpoint arrows on the blueprint wires turned on, I highly suggest it. Here is a link to my blog, where I give the instructions on how to turn that on.

/b2evo/index.php/iwue4dev/blueprint-tidbit-2

Have a great day!

Inc.

So this is what I currently have based off of what you’ve done- while the actors are spawning at the right locations they are still spawning together a lot rather then at separate points. Can you see what I may have done wrong?

How often is the For Loop that is driving the entire process of spawning being called? what is the value of “bots to spawn” (the max for the for loop), being set too?

The for loop, depending on how often it is being called, and how many bots it is going to create per call, can make it appear that it’s not working.

If only 4 points to spawn at, there is an “edge” condition in the way that I slapped this together, that gives a 25% chance of reselecting, the prior spawn point.

Pass N - spawn point selected and removed, but now the “in use” array is empty, i.e. length = 0

Pass N+1 - In use array empty, and is refilled, but now because of only 4 spawn points, we have the 1 in 4 chance, that we will select the same spawn point, that we did on Pass N, because it is now back in the array.

to remove a condition like that, would take more nodes for sure. As you would need to test again, after removing the spawn point, and if the length was zero, set a boolean, to remember that you should not select that same location. Then save off that location in a variable, load the in use array from the master, AND remove the location you just saved off in the new variable, from the in use array. then on the next iteration, you would check the boolean (after you have selected the new location), it would be true, then take the saved location and put it into the in use array, and set the boolean to false. That would absolutely guarantee that the same location would never be selected twice.

The For Loop, depending on how fast it’s called, and how many it spawns at any one time, aggrevates this “edge” condition. Or so I think, because I have a feeling it’s spawning more than one bot per call, and the bots are being spawned irrespective if any other bots have died.

Hope this helps!

‘Bots to Spawn’ is a user selected number of how many enemies bots you want to play with (Minimum of one, maximum of four). Right now it’s just set to four, to test against my four Spawn points. So the loop goes 4 times for 4 actors to spawn at 4 different points. Due to the type of game it is, there are no respawns or extra times that the spawn is ever used. It’s like a bomberman style game, where the last player wins the game, so I need the bot’s to all spawn at the same time but opposite sides of each other, and as each bot ‘dies’ no bot replaces it.

Like I said I’m quite a noob and didn’t expect it to be so complicated haha, in theory it seemed like a simple idea to implement.

ok, here’s a quick and dirty way to accomplish it. I turns the “reload” into a “rolling selection” if you will, and has no “seam” from the reload.

This assumes that your “Spawn Point” variable is not a local variable.

After the reload of the in use array. Instead of wiring down to get the new location and the set of the “Spawn Point” var.

Create a new node of “Remove Item” for the “in use” array, then wire up the “Spawn Point” var for the item to remove.

Then wire from the remove item node, down to the set node, for “spawn point”.

This will reduce the number of nodes in potential set to 3, but it’s a “rolling” because it’s easy to keep up with “spawn point” as “variables” in Blueprints are global in nature, unless they are local.

Hope this helps,

My spawn point is not a local variable thankfully. I sort of understand but would you mind sending another image if you have the time? I struggle to understand from just text. Sorry for any inconvenience, I do appreciate the help.
Also, would it be easier for me to just spawn 3 bots, and then a player also at a random point, because right now the player only spawns at one point while the bots are meant to be random but I was going to change that way down the line anyway, I guess I’m asking if including the player into the random spawn will save me a lot of trouble later?

The number of bots that you are spawning, has no impact on reselecting a spawn point, on the transition from “empty array state” to “full array state”. Nor does anything else really, the “condition” will always exist.

To handle a player spawning at multiple random points, you would just take what we have here, turn it into a function, and pass in

  1. in use array
  2. master array

And then let the function take care of the selection of point, and refilling the array etc. then it would return to the caller, the location. Then you can use the returned value to spawn a bot or a player, either or.

and if ya like this answer, be sure to accept it! lol

Thanks for all of your help, I hope I didn’t take up too much of your time. I think I need to hit up some more tutorial vids before I find myself in another situation like this!

You are more than welcome of course, and I hope that the “code” works for ya!

I have been categorizing some of Epic’s tutorials, that might be helpful for you as well.

/tutorials/iwue4tutsindex.html

Just click on UE4 Tutorials when you go to the site.

Hi, I am curious if you every got this to work out. I am trying all day to achieve something similar but i cannot seem to get it to work.