How to draw an outline around multiple hexagon game objects?

Hey again everybody :slight_smile:

My question is, how would I go about creating an outline around multiple hex tiles such as in the picture below? And on that note, around hex tiles in oddly shaped patterns, such as if an object was in the way of multiple tiles? Note: think the new XCom game, the way they show the movement ranges of the units… but in hexagon format.


The backstory of the project I’m working on is that it is a hex-based strategy game, and the movement and attack ranges of the units would be shown on the hex tiles.

I’m stuck as to how to solve this problem though. I’ve had multiple ideas of how to do it, ranging from using a projector and hex outline shape (wouldn’t be valid at some times, as the move range could be blocked & reduced by a wall), using the GL class in unity, and even line renderers.

The GL class and line renderers seem like they could do the trick, but with either of them, I am unable to find the vector3 points of the outlines of the hexagon tiles. Well, I can find them using:

Mesh mesh = GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;

…but the vertices it provides me with are vertices around the game object (hexagonal prism as it were) as if the game object was sitting at 0,0,0 world coords, which it is not.

Does anybody have any suggestions of how to solve this, or even suggestions of an alternate way to do it?

If it were mine, I’d highlight the affected/affectable tiles, rather than the outline. Much more generic and flexible approach I reckon. It’d allow you have indents in the area, or allow for line of sight and the like much more easily, rather than trying to calculate the outline shape.