How to Stack Static Meshes with Different Heights on Top of Each Other Using For Loops?

Hi,
I want to stack several randomly chosen static meshes on top of each other using a For Loop. The meshes are selected from an array.

The problem: the meshes have different heights, so I can’t just multiply the loop index by a fixed Z offset. I want each mesh to be placed directly above the previous one, regardless of its size.

I’ve spent two weeks trying numerous approaches using GetComponentBounds, offset math and more – but nothing worked reliably.

I have not posted any screenshots because I have tried so many different things and honestly don’t know anymore what I’m even doing. I feel completely stuck at this point.

Does anyone have an idea how I should best approach this? I’d really appreciate any input. Maybe someone knows tutorials or similar resources on this topic because I haven’t found any.

Thanks!

1 Like

Do you mean random meshes in the level, or mesh components in a blueprint? Also, why for loops? Can you describe how it works?

Basically you have to know the offset for each mesh, there isn’t really a way to generalize this, which is probably why you’re struggling.

Something like this is possible using component bounds, but not if the meshes will be rotated, and then the bounds changes shape.

Also a lot can vary depending on where the pivot point is in the mesh.

Spawn the new mesh under the map and get its bounds (z). Do a trace from above the last stacked mesh. Take the hit location and pad the Z with half the bounds of the new mesh. Then teleport the new mesh.

Hello,

You could try something like this too, as long as your pivot point for each mesh is at the bottom.

Adding static mesh component, setting random mesh from array, getting that mesh local bounds, taking away min z from max z and adding it to current z (default 0).

You can easily edit pivot point using modeling tools.
Drag static mesh you want to edit into a level. Switch to modeling tool.

Don’t forget to Accept changes.

Screenshot 2025-08-03 010323

1 Like

(post deleted by author)