I’m seeing a few other posts dealing with procedural generated stuff, so I went ahead and put together this larger example on using the InstancedStaticMeshComponent:
Image Link
Which results in this:
Image Link
The small square there is a single static mesh, while the larger one is a grid of 32x32 of that same static mesh.
Let’s walk through the graph:
- Set our GridX and GridY Size to 32 (which I should only use one cause the math later should fail on non-square grid)
- Add our InstancedStaticMeshComponent at 0,0,0 in the Blueprint (by trying to connect a vector3 to a transform, you get that handy conversion node)
- Then we set the mesh to our grid space
- Store the InstancedStaticMeshComponent as a variable for easy reference down the line
- Start a for loop that starts at 0, and ends at (GridX * GridY) - 1 or 1023
- We then divide and mod our index to get an X and Y coordinate, multiply by 100 because that is the size of the tile, then put those into a vector3 (dragging off an into to float creates that conversion node)
- Then we Add an instance to that InstancedStaticMeshComponenet at the vector we created (handy transform node again)