I Have been looking for a tutorial for this kind of thing for a while now, and have found none that solves the problem since it is a niche.
I assume what you want is something like this.
A line that surround a collections of hexagons.
I will also assume You have the following:
- A list or array of the tiles needed surrounding(and that it only needs 1 outline)
- A way to grab the surrounding 6 tiles
- A outline that can be generated by a series of points
I will be numbering the surrounding tiles as
First, pick any edge tile in the list.
Check the tiles surrounding it in order.
If the tile is not in the list. We that segment to the outline. and continue.
If it is, we move to that tile, remembering which direction we came from.
In this example, We check the 0 and 1 tiles. they are not in the list. Then we check the 2 tile, which is in the list. so we move to that and repeat.
But now, we start to check from where we come from. we came from number (2 + 3) % 6 = 5 relative to the second tile. So we start checking from 0.
Continue until you reach the first segment(not tile) since a tile can be visited multiple time.
This will not work when tiles are not at the edge already.
This will not work when the tiles are not connected or when the outline needs multiple lines.
If you know how to improve this, please tell me