Method FindNearestPointOnHexGrid
FindNearestPointOnHexGrid(Vector2, float, Orientation)
Finds the nearest snapped center position on a hex grid for an arbitrary point.
public static Vector2 FindNearestPointOnHexGrid(Vector2 p, float hexRadius, Hexagon2D.Orientation hexOrientation)
Parameters
pVector2The point to snap.
hexRadiusfloatThe radius of the target hex grid cells.
hexOrientationHexagon2D.OrientationThe orientation of the target hex grid.
Returns
- Vector2
The closest candidate center among the four neighboring snap solutions sampled around
p.
Remarks
The method samples four offset positions around the query point, snaps each one independently, then returns the closest result. This avoids some orientation-dependent edge cases that arise when snapping directly once.