Blueprint Instancing Error

I am making a blueprint to utilize nanite high-poly meshes, and 5.1’s new ability to use material alpha on nanite meshes. The idea is a sort of floor bp (which could later be modified for walls, roofs, etc) which can be either rectangle or right-angled triangle in shape, where in the detail panel in editor, I can define a width/length in 10cm increments and based on the mesh_id variable, spawn a grid of nanite floor tile meshes, and I can then use alpha cutout to to solve the fact that the nanite meshes can’t just be scaled to fit whatever overall x/y scale I set.

One big problem I seem to be getting, is per loop when I create a mesh instance, I seem to get some unpredictable results. See the images below:






In the construction script, I am doing everything inside a function (see#2), and among the logic, including clearing all instances at the start of the function, I get to several placing where I reach the proper conditions to call my function (see#4) that sets the instances. This is important and where I am experiencing issues. You’ll see within that function I have a sort of debug function (see#5) so I can see in the editor some various stats per mesh, which for now just prints a “0”, but it doesn’t always spawn as you can see in the first image. You’ll also notice from the third image that I am not setting my colour tint (in the logic of the angled version, these are the meshes that will have an angled alpha cut) but in the first image again, while some of those meshes are black as expected, some just aren’t getting any material info set at all.

Just one more note to try and best explain my bp logic. Each mesh Id is attached to an array of instanced static meshes, with the idea being that for different ids (marble tile, stone tile, etc) I could have X many variants that get randomly used, but I didn’t want X to have to be set the same for all ids. I should also note that if I change my initial seed, I get a different output of meshes that don’t get material data set and whether that mesh spawns with a “0” over it or not.

And to clarify on the desired setup, I want all the meshes in the first image to have the “0” over top, and all meshes that don’t have that stone texture along the angled edge should show up black.

Any help with this would be much appreciated and sorry for all the text. (If there is an easy way to share the whole bp, including all functions, I would be happy to do so if it makes debugging my problem easier, thanks again.)

Max is length - 1


LASTINDEX is more handy.

Good to know, thank you. I am still having the same issue though as far as instances not getting material data and text render components not spawning.

1 Like

Did you change it, as both the mesh and the material are being chosen by this macro?

Ok, I see more…

Let’s take ONE mesh I intend to instance. I can set the mesh and assign a material. Then I can instance it. All of the instances have the same mesh and material.

If I want another mesh or material, I have to make a new mesh I intend to instance.

I see in your code you’re constantly reassigning the mesh and material of the original.

Check out:

1 Like

Sorry for the late reply, the holidays kind of took over for a while. Using what you said, I moved my “Get Random Array Item” macro to the outside of my “Build Block Alt” function, just piping the single array item into the function, and the tile blocks are all being added/spawned as expected. Thank you.

1 Like

Thank you, I will have to look into this as well.