Spawn Random Mesh in Volume

Hi UE4 Users

I’m currently working on a first person shooter game where the map is randomly generated every time you play.
At the momment I am struggling with spawning the map randomly. I thought I had something that worked but it didn’t sadly so I am in desperate need of help :slight_smile:

How I wanted it to work was when a player entered they would run through a box collision that would then trigger the map to spawn all it’s objects. On certain areas of the map I want to spawn one of the potential actors (static meshes in this case) but randomize what actor spawns. I know I have the first box collisions sorted but am struggling to set up spawns for the actors. Please help :slight_smile:
Thanks a lot

You could create a Blueprint (Based on Static Mesh as parent) and in that Blueprint create an Array of type Static Mesh add all the random Static Mesh’s into the array.

In the construction script of the Blueprint you get your Array variable pull of a ‘GET’ this will allow you to get a Static Mesh with an INT then just use the Random INT node and set the range.

(i.e if you have 12 Static Mesh in your array set the Random INT range from 0 - 11) then set the ‘GET’ result as a static mesh. This will randomize at begin play every time.

Now in your level where you want to spawn your Static Mesh add a Target Point then in your level blueprint get the transform of the target point and do Spawn Actor by class and add the transform to Spawn actor and set the class to be the BP you created above. Make sure to attach the Spawn Actor to the trigger you set off when your character walks into it.

I am not at my computer so this is all theory but in my head it should work fine…

Give it a go and let us know.

Hi, thanks for you reply. I just tried this but I get an error when trying to attach the other actor blueprints I get an error saying they are not compatible with the blueprint in “array slot 0.”
Any ideas???

Not sure your exact set up. The Static Meshes you have are just Static Meshes or are they in a Blueprint already? There are two forms of Static Meshes I believe Actors and Components. Maybe try to make your Array type Static Mesh Component instead of Actor.

They are in blueprint but dont need to be. How do I set the array to static mesh?

This explains what I am asking you to do best.

YEEES! It seems to be working now! Thankyou sooo much mate! Really appreciate the help! :slight_smile:

Always a pleasure, your game concept sounds interesting. Have fun.

Cheers mate, have a great night. :slight_smile: