Procedural Randomization

appreciate that. I do have the meshes imported separately now.

Right. Make an actor BP, one variable, which is an array of type static mesh. Also give the BP a static mesh component, like this:

In the construction script:

That’s it!

random mesh

Hmm seems doable. Let me ask in the static mesh is that where I would define the number of buidlings…A,b,C etc?

Like this:

you can also put this on the end of the script to get random Z angle ( in 90s )

awesome. Thank you! I will work on this later this afternoon. Will let you know how it goes.


1 Like

I was looking at each bldg as a prefab vs a single static mesh.

1 Like

why cant I find the Set static Mesh function?

Drag & drop Static Mesh Component reference into the graph (from the Components panel) , drag a wire and search for what you need.

Nodes are context sensitive, while what you ask should still pop up in a regular search, not everything does.

I actually did that but its not giving me the same thing.

You mean this:

Or what are we doing?

I am dragging the static Mesh variable that I made. I do not have a static mesh where you are grabbing from. Should I?

Could you show a screenshot of what you’re doing? There should be no need to manually create variables. But if you created a variable to reference a static mesh, you can set it directly in the details panels:

Also, since we’re talking about random grid gen, consider taking this 2D Grid Execution node for a spin at some point:

OK I know what I was doing wrong. I made a Variable called static mesh instead of making a component static mesh.

I deleted the variable static mesh and created a component static mesh and it works as it should.

I have about 7 meshes so I am using a static mesh variable set to an array to give me the random ability to drag and drop building in.

Makes sense. So is it working the way you need it to?

Yes, thank you for your help. Its doing what I though it would do.
Let me ask another question. Lets say I have 3 different materials for each building. IE For buidling A has 3 materials. One shows the building color gray, one is red and one is brick. How would I get those material to show up randomly when I am dragging out or coping this blueprint.

So right now it works everytime I move or copy the bp it randomly creates one of the 7 buildings but they ( A,B,C,D,E,F ) always have the same material on.

I hope that makes sense, lol

The most straightforward method would be quite similar to what you’re doing with the meshes. Something along the lines of:

You can fetch materials from an array or even from a Select node. There are better, more sophisticated and convoluted ways but that’s the gist.

OK great. I can play around with that. I was thinking maybe it could be done in the material itself? PerinstanceRandom?

Sure, a dynamic material would work well:


You could feed DMI (Dynamic Material Instance) a texture param. Colour would be a vector parameter.

There’s probably a dozen ways to organise it. Here’s an example with Custom Primitive Data, if colours is all you need, this is crazy efficient:

Although you’ll probably find better examples on YT.

So I am back on this today. I set up the BP correctly, I think.
My Select has 3 different texture maps set for 3 options. The create dynamic material instance Function has the parent set to a material that has one texture map set for the base color. I defined the static mesh with one of my buildings and the same material that is in the create dynamic material instance function.

I am a little lost on what is supposed to happen now? It doesn’t seem to be working.