Procedurally add random Mesh in construction script

Hello, everyone!
I have created a blueprint that adds meshes according to the position of a vector variable, very similar to the one in this tutorial:

I made some little alterations so that only the x-value matters at the moment and the meshes also get added correctly when the x-value is negative.
This works perfectly fine until here.

However, I wanted to add random meshes instead of just one.
So I changed the loop body to go into a branch first. A random float gets created and if it is <=0.3 one mesh gets added, if it is larger than 0.3 but not larger than 0.6 a different mesh is added instead. If that is also not the case another mesh is added.

However, this causes a very strange bug.
Some of the meshes are missing. No matter how far I move the EndPoint on the x-axis, the problem always seems to appear only in the first couple of meshes. However, they are not always the same ones.

I enabled Simulate Physics in the Add StaticMesh nodes to see if there are some overlapping meshes and it seems like the missing ones are always stacked on the very last one.
I might have some logic mistake in my blueprint but I just can’t figure it out. It’s just so weird that the problem only occures within the first few meshes. I even set the x-value of the EndPoint to 1 Million, adding 1000 Meshes. Still, there only were missing ones among the first few. When the x-value of the EndPoint is rather low there are 0-2 meshes missing but when the value is quite high they seem to be always exactly 2.

Also, my method of choosing between random meshes seems quite dirty. Is there a better way? For example using arrays or simply a node that randomly fires one of its outputs?
And one more question: Does the random float gets randomized both times it is used in my blueprint or only once per loop? Either way, I tried avoiding that by creating a variable that gets set to a random float every time the loop starts and then use the variable instead of the random float in the picture above. But the results were exactly the same.

I looked but i didn’t see anything out of the ordinary of why this would be happening.

Did you make sure the second and third meshes were set ?

EDIT - This is how I do it normally. This is how I do it randomly.

Yes, all the meshes are set correctly.

not sure if you seen but i added some pictures :slight_smile:

Try to set the add static mesh all to the same mesh, to make sure it isn’t a problem there ether being a bad mesh, or having the mesh offset causing a problem with relative location.

Where you multiply the end point by 1,0,0 then get the vector length, you can just use the X value where you break and use the X value instead. As the vector length is only going to be the x value.

Sorry for the late reply, I had lectures today.
I finally got it to work, based on SaxonRah’s blueprint.
Thank you so much!
I don’t quite know what it was but I think the problem had something to do with setting the mesh directly in the ‘Add StatMeshComponent’ node’s details instead of setting it separately with a ‘Set StaticMesh’ node.
Also, I just realised I used three almost identical looking meshes in my post yesterday which made it quite hard to understand. Sorry about that.

I’ll try to get it work on the y-axis as well. I’ll post the whole blueprint here once I get it to work.