Random instanced static mesh not working

In a construction script I’m adding an instanced static mesh. Just before I’m adding it, I call upon a function in the same BP that I want to randomize which mesh it shall set before adding it in the world.
It doesn’t work. It always sets the first mesh in the switch on int that I use in the function.
I attach a screenshot if the function.
Any ideas why this doesn’t work?
Thanks! :slight_smile:

Forget the random stream and just use RandomIntInRange.

The whole point of streams, is they are repeatable, which is what you are experiencing.

1 Like

As above; also it may be worth looking into the Select node. The setup could look like this:

Fewer wires, less space taken, easier to read once you get used to it. One needs to be aware of how evaluation works, though - so it may not be suitable in all scenarios.

1 Like

Thank you so much both of you for the tips - however none of them make any difference when it comes to the selected mesh being the same for all instances. :frowning:

What I’m doing is that I’m looping the instanced static mesh generation along a spline’s length and I want the set mesh to be randomized for each instance.
I use the above randomization function once each loop, but it seems like it only works on the first pass and then the mesh remains the same. Everything else works as expected - scaling, spacing etc. so the basic loop is ok.
This is done in a construction script.

An Instanced Static Mesh Component can only have 1 Static Mesh:

It can then instantiate that one mesh many times, and very efficiently, too!

If you wanted to have 1 trap (we’re making traps, right?) with many different spikes and still use ISMCs, you’d need more than component.

So you’d need 4 ISMCs, each with a random spike mesh and then let each ISMC instantiate its own spike Static Mesh. Or use many Static Meshes instead which can be added dynamically.

At the moment it seems that you’re attempting to have 1 ISMC have various meshes assigned, that’s not going to happen. Perhaps you could tell us more about the spike actor you’re designing - we might be able to push you in the right direction.

Of course! Thank you, I’m so stupid. :slight_smile: Now it works! :slight_smile:
And no, it’s not a trap, it’s a palisade! :slight_smile:

1 Like

Fair enough! :smiley:

1 Like