Spawning Multiple items to Target Points

Hello,

Right now, I have a working spawner that can spawn one item in random places. This is exactly what I need, but I have six key items I need spawned instead of one. Does anyone know how to set this up for multiple items? Would C++ be a better way to do this? (If so, please give me a starting point, I have already mixed C++ and blueprint in my project.) Or is it just okay to copy and paste this 6 different times?

Here is the Blueprint:

You could use a for loop to repeat that operation any number of times you need

https://docs.unrealengine.com/latest/images/Engine/Blueprints/UserGuide/FlowControl/ForLoop_Network.png

This works partially, the only problem is that when items spawn, they can spawn into/on top of each other. Is there a way to make sure they all go to separate spawn points?

Yes that is perfectly possible. How many spawn points do you have?

Right now I have 6. The example I showed above was me just testing with 2.

Ok what you need to do is something like this. You should create an array that has the references to your 6 spawn targets. Then on each loop cycle after you spawn your object you take the index that you used and remove that from the array. So each time the array gets shorter, just remember than you should take into account that since the array is getting shorter your random integer max should be reduced by one every time.

Something like this

I totally understand what you are saying in concept, but in Blueprint, what would I use to take the index of the array to remove it? I’m fairly new, and have only been studying C++ for a month and Blueprint in even less time.

So when I used a Integer - Integer function, they all spawn in the correct places with no stacking. So now the only problem is getting them to spawn randomly between the 6 spots. ( I plan on having 12 spots, so that the keys will always be in a different place, without stacking) haha
This is what I used. I was using random integer in range to make them spawn in random spots, but in order to get them to not stack, I used Integer - Integer, which no longer has them spawn randomly just in order of the spawns.

112970-blueprint2.png

which no longer has them spawn randomly just in order of the spawns

Well that’s because you are using the index from the for loop and not the index from the random integer node. Did you try it the way I did in my image?

Edit: Besides I just noticed that you aren’t even using an array variable, did you even check the image I posted?

This is method you’ve created works, but they are still spawning on top of each other.
The items I have for testing are these boxes. As you can see they are spawning and then just stacking.

Yes, I re-did everything in your image (:
I had seen it a bit too late, so that comment came before.

Oh sorry there was a mistake in the code that I posted. I assumed that RandomInteger would return the same value for both of the pins if it was accessed within the same line of execution but it seems like it isn’t that way. What you need to do is to create an integer variable and then set it with the value from the random integer node then connect that variable to the Get node and the remove index node and that should do it

Thank you for trying, but it still didn’t work out. When I added the integer, it just make them spawn in a row again, as in 1 - 6 slots every time. ( I have 8 slots currently so in theory they should randomize between them). Maybe I should just find another way to go about this, I don’t want to wear you out. haha.