Download

How to keep an island from being split in two by the player

So in my project the player can add and remove hexagonal tiles to make an island. However I would like to stop them from being able to “split” the island in two.
When adding tiles this is easy enough (just make sure each tile connects to at least one other) but I cant think of a way for the UE4 to know that if the player deletes a tile it result in two district “islands”, so that it can block the action.
I’m not the best at explaining myself on reddit so hopefully the picture will make it clearer.

Really appreciate any help that you can offer.

I don’t think unreal has anything like that for users. You could study graph algorithms to determine if your islands are connected and implement it yourself.

Ye i thought maybe there was something built in that would be cheaper but it looks like im going to have to build an algorithem. thanks :slight_smile:

Actually there is a unreal build-in function for this. You can use FloodFill from AGraphStar and check if the tile you added is in NodePool. If it is, then you are connected.

That’s great thanks :slight_smile: Ill give that a shot.