Procedurally Generated caves

Hi everyone,
First off, thank you for all the help! I am new to Unreal engine, as well as the Unreal engine forums, so any help is much appreciated. I am trying to procedurally generate a cave using blueprints, and actors and meshes that my team creates. I am testing out the blueprint logic with in game meshes such as couches and lamps (hahahaha).

Here are the blueprints for my “cave”:

My theory to procedurally generating this cave is to have an array named “Walkthrough” filled with all the possible options for cave pieces. I then have a for each loop, and it loops through the array of actors. For each actor it should add a static mesh. I want to use the static meshes that are attached to the cave pieces, but I only figured out how to apply one mesh to all of the pieces. And it had to be a mesh that exists in the original program without any editing. After each piece is created, I attach the next piece to the previous one, and position the pieces.

Here is my attempt to do the generation using couches instead of cave pieces

Overview of problems:

  1. I don’t know how to get the position of the couches to move through drag and drop. No matter where I spawn the cave blueprint, the couches spawn there
  2. I don’t know how to get blueprints to let me use a variety of meshes that I choose, I can only figure out how to pick one mesh that is inherent in the program.

Any help would be much appreciated. I am open to both tips/solutions to my problems, as well as any other ideas on how to procedurally generate a cave.

Thanks everyone!

You’ll want to get the transform of the owner actor and then do “Transform By” the location you set on your spawned meshes.

You’ll want to import any meshes you need to use for your generation before hand (so, if you have FBX files for your pieces of the cave, go into the Content Browser and click “Import”, then they’ll show up like the couch - if you select “Import Materials” it should create the materials for you).

Thanks! And is there an option to let me pick more than one mesh? I want each cave piece to have a different mesh :slight_smile:

Switch on Enum with each output leading to a different mesh. I suggest creating an Enum asset over using Switch on Int since you can name each remember in the Enum which makes it much easier to remember what leads to what.

Thanks, I think I am slowly understanding.

Here is my new blueprint:

Is there any way to use an Enum array and have a random enum from the list picked to use as the value? I.E. instead of connecting “glass door” to “switch on enum” I would connect an enum array and somehow pick a random value out of the array.

Solved it, thanks for all the help guys!!!

Alternatively, you could have an array with all the meshes and call a random mesh by plugging a random int into the “get” node.