I think the RandomPointOnSurface() should return the point which is inside the GridNode, but when I try to pass the random point to GetNearest() it sometimes will return the other GridNode, check the code below, it is about 20% that it will return the wrong point that is outside the GridNode.
GridNode gNode = ...
int correctCount = 0;
int wrongCount = 0;
for (int i = 0; i < 1000; ++i)
{
var kNode = gridGraph.GetNearest(gNode.RandomPointOnSurface()).node as GridNode;
if (kNode == gNode)
{
correctCount++;
}
else
{
wrongCount++;
}
}
Debug.Log(correctCount);
Debug.Log(wrongCount);