Need help with spawning multiple actors at random locations

Hi. I attached a screenshot of my blueprint. Basically, I want to spawn a number of actors whose transforms are stored in an array. Every thing seems to be working alright; it spawns the right amount of actors based on the size of the array. The only problem is that the actors are all in the same location. Each time i start the game, the actor spawns in a random location within the range of the coordinates I specified, but the other actors in the array are spawned in the same place. Some help would be great. Thanks :slight_smile:

I think you are only getting 1 random location. You should get a new location in each loop of the sphere list.

You need to put the call that’s getting the location in the loop, off the loop body pin, get the location there first. I’m not exactly sure what’s going on with your add, I have only used the get random location node, but try moving the add node to the right of the loop body pin, and then off it’s output spawn the actor but take it’s new output.

I don’t think you need an array of locations, just loop on the number of spheres you have, and then get a new random location for each.

Yeah, I’m just not sure how to do that. Do I need to add more nodes or rearrange what I have somehow?

I think you’re right about not needing an array. It will actually make things simpler. The thing I am confused about is how to do something like “make transform” inside of the loop. It doesn’t have an exec pin so I’m not sure if it’s possible to do it that way.

Hmm, yeah get random location in radius definitely sounds simpler than entering in manual ranges :). I got it fixed. Thanks so much for your help; the for loop without an array makes things a lot simpler! Here’s the working blueprint:

I think it will get called each time if it’s the input to the Spawn node. There is a node called get random location in radius that you may prefer.

How come this answer was accepted? When I answered it. Curious.

You were right about not needing an array. I used a for loop and now the objects are spawning perfectly. I haven’t tried to use the function to get a random location in a radius but I definitely will as that will simplify things. Thanks so much for your help :slight_smile:

KaladinRahl - could you post a screenshot on the blueprint that worked for you please?
Best regards!