How to get the vertices/corners of hexagon grid nodes


#1

Is there an easy way to get the vertices/corner positions of nodes in a hexagon grid? I’m creating a tbg and I need some way to draw graphics in game for the hexagons that is avaialable for movement. (the gameobject solution in the turnbased example is not an option, since my map is using heights). My plan is to use a linerenderer to draw hexagons with the node corner positions.

BR
Henrik


#2

Hi

Currently there is not unfortunately.
However you can take a look at the code that the grid graph uses to draw them in the scene view. It is the GridGraph.CreateNavmeshSurfaceVisualization method. That one draws both the surface and the outline.


#3

Ok I will have a look. Btw I tried the beta method getcontours. Its nice but not what I want (it also doesnt work together with constantpath if you dont reach any edge of the grid.)

Anyway - there really should be a getNodeContours method also. Consider it a feature request!


#4

Hm…
Won’t GetContours for each individual node work though? If you just give the GetContours method a single node at a time then it would output the outline for that node.
https://arongranberg.com/astar/documentation/dev_4_1_8_94c97625/graphutilities.html#GetContours
It wouldn’t have the same height information as the CreateNavmeshSurfaceVisualization method uses though.


#5

Great site about hexagonal grids: https://www.redblobgames.com/grids/hexagons/


#6

A bit late, but this bug has been fixed in 4.1.10 btw.