BP that assigns random material?

So here’s the scenario- I have a library scene with an assortment of different book meshes scattered about. They all use the same static mesh, but I have a variety of different materials created for them to make them look different.

What would be the best approach to randomly assign a material to each book upon spawn?

I’d probably make an array containing each material then use a random int(the size of your array) with the ‘get’ node to assign the random material. I can elaborate if you need.

Alright, that sounds good. I am having trouble referencing the various materials though, as they aren’t all applied to the static mesh in this blueprint. How might I go about adding them to the array?

Figured it out. Just used the “set material” nodes and randomized it with a Switch on Int.

You could also use the “select” node which is often overlooked. This performs in a similar way to a switch, but it requires less nodes as it just picks the result for you.

Hi Necro_ABK. How would you go about creating array of materials? I can’t seem to find any good info on that.

I made a short video that should help you out. Random Material From Array UE4 - YouTube

Hi, thanks! That’s great. In the end I solved it myself after a couple of hours. Here is my BP setup.