Spawning multiple actors of varying amounts

So i am working on a script to spawn a squad of units.

I can get the actors spawning. i can get them spawning in different positions. the problem now arises that when i want to have a minimum and maximum amount of each actor to spawn in this squad, i cant get them to form correctly.

I’ve tried fiddling around with compare and Do Ns but i cant seem to figure it out. Any help or suggestions?

You have the min and max numbers right?

So you simply need a random number between those two values and feed that into another for loop.

The “Get random integer” function provides you with a number between 0 and an input value. Subtract min from max, input it there as max, add the min squad members onto this random integer and feed that to a loop. That should do the trick.

I hope this helps :wink:

Cheers

Like this?

As when i do that i get close to the result i want, but if you look below, there is one more box than should be.

31574-capture2.png

Max - min. Not the other way around. Not 100% sure if that’s causing your bug. I’m on my phone right now and it’s rather hard to figure something like this out. Let me get back at my pc and I’ll post another reply in an hour or such.

Edit: Er no? There isn’t one box too much. Min 1 box, max 4. 2 boxes is within that.

And apparently the negative number you input into your subtraction is handled by the random integer function so yea… That works.

There should only be 1 box and 4 spheres.

The min value is for how many that is spawned when the squad is created. The max value is there to limit how many of that type of that actor can be created for when you reinforce the squad later.

will change the min and max around and see what happens.

Wait what?

So… you don’t want to spawn multiple actors of varying amounts but always the min amount? Then just remove this calculation and the random integer there and simply put your min into the for loop.

Though I have to admit from what you told so far what I described seemed like exactly what you want.

Was one of the first things I tried before asking, still isn’t giving me the results I need. I tried to have a less ambiguous description, but it’s a lot more complicated than it looks.

What currently happens is that will spawn the first squad entry and add 1 to the minimum result regardless, so if set the cube to spawn 3, it will spawn 4.

Then when it moves to the next squad entry, say spheres, it will overlap the spawn location, even though each location entry is different. So that’s also not good.

What should happen:
So for example I have 3 different types of actor listed in My SquadLoadout struct. I have 3 of each actor. (This is where min comes in)

So 3 Spheres, 3 Cubes and 3 Pryramids. I have set a 9 space formation for them to fill and they cannot over lap.

SSS
CCC
PPP

So one actor type needs to be spawned first, then the next in the list so the formation gets filled out.

I hope this makes sense.

Also thanks a lot for the first solution, that is gonna be so very useful a bit later, as I am gonna have a lot of randomized visual based stuff :slight_smile:

Ok, so i’ve managed to get it working like this. Thanks :smiley: :smiley: :smiley:

Now to start adding the other features.