Download

Scatter array of static meshes on plane with minimum distance between each

The Content Examples Advanced Blueprints Level has a demo of scattering static meshes but there is no minimum distance between each so they can overlap.

How would I modify this so that there was a defined minimum distance between spawned static meshes?

How would I modify the demo so I could spawn on a publicly defined target mesh or plane instead of in a circle?


There are a number of ways of doing this, mainly depending on how long it can take to do for very large numbers of meshes.

The simplest way is to generate the full scatter, then remove any mesh that’s too close to another. If you still need exactly N meshes created, then start tacking those on “on the outside” – maybe poking outside the original scatter area. To remove meshes that are “too close,” you’d iterate over each mesh, and compare it to every other mesh, which ends up being o-squared in cost.

A more efficient way is to scatter the meshes on a grid – perturb each mesh by some amount from the well-aligned grid point. Make the grid spacing big enough, and the peturbation small enough, and you will be guaranteed no overlaps.

Fancier algorithms exist, and I think there was even a thread a while back about how to spread objects out without being too close to each other; tons can be written about it. Search the forums and see if you can find it!

1 Like

This seems related:

That’d be the one of many methods:

A more efficient way is to scatter the meshes on a grid – perturb each mesh by some amount from the well-aligned grid point. Make the grid spacing big enough, and the peturbation small enough, and you will be guaranteed no overlaps.