Advice for a noob: spawning Dynamic actors

Hello all! I am starting to piece together a simple puzzle game that involves a really big crane and some cargo containers. The blueprint I am working on right now will become my method of spawning new containers for every level. Right now it simply fires when a key is pressed, although eventually I want to fire this at the start of every new level, and run for a pre-determined number of times based on what level the player has reached. It spawns an actor from class at a random point in a volume that is placed in the level. My first question is, how can I spawn containers that do not overlap in XYZ space so that they stack neatly inside the volume. I am thinking I need to add every new actor to an array, and then I can get the positions of the actors in the array and add my new position to that. Am I getting warm?

The second question relates to the spawn actor from class node. Is it possible to feed the random result from a list of other blueprints into this? I have four color combinations and two sizes of container that I would like to spawn randomly. Right now I have a separate blueprint for each color/size combination of containers.

Here is my blueprint so far:

Here are a few spawned containers:

Here is what eventually happens when a newly spawned container doesn’t line up with the rest of the objects:
8456f39238fef0854f1c829d222e71061bc96a61.jpeg

Hey there,

for your first question you could check for collisions with other objects, when spawning the container.
Check the foliage Blueprint in the BlueprintExamples. I think there you can find what you need.

For the second question. You could create an array of those conatiner and when spawning a container you’ll create a random integer(Random Int in Range) between 0 and the length of the array.

Cheers

Xypher

To the second question, I did something similar with my platform game. How I approached it was to put all the logic into my object, a simple platform:

Options:
Color - Red, Blue, Yellow
Powerup to spawn - Coin, Super Jump, Slowmo, Invincibility or None
Movement options - Stationary, Vertical or Horizontal

This way, when I create the levels I can set exactly what I want for each one with only one object that’s easily cloned around the level. Then I set up a random system in it to choose a random int in the desired range and then switch on int to go to each one. i.e. Blue in the editor dropdown enum sets the color of the platform to blue, sets the int to 0 (always 0=blue in my system). Then for random, if the number returns 0, the switch just pipes everything through the same nodes for 0/blue.

So, to solve the issue you describe I can just set the default of each of those options to be Random and when I spawn it with a similar setup, it’s always different. You can expose those variables to a spawner too so you can lock something if you want. i.e. Always spawn as blue, but everything else is random.

Hope that made some sense. PM me if you want more info and I can take screens of my blueprint layout for you.