Grouping sets of actors in runtime

I’m working on world gen for my 2d game and I need a way to select groups of ‘touching’ actors. Heres what it looks like currently:


Each set of circled actors needs to be grouped into seperate groups. each square is its owner actor placed on a grid.

I want the sets of actors to be placed into an arrays so i can modified them later.

any help is appreciated, if you need more explanation i’d be glad to tell you.

Hey @Quikiki0

here is one example. It is not fast but maybe can give you an idea:

UE52_GroupActors.zip (85.1 KB)

This is a great solution for smaller projects but my world is 100 x 100 with potentially 5k+ actors to check and your example crashes with a 20x20 on my computer.

Thanks for spending the time to demonstrate though I appreciate it!

A faster approach, still without C++:

UE52_GroupActorsV2.zip (163.2 KB)

Otherwise look into clustering like K-means and the silhouette method