GridNode versus GraphNode... How can I make this work?

I thought I saw somewhere on the forum that I should be able to do this…

var gridGraph =;
pathTarget.position = PathUtilities.GetPointsOnNodes(gridGraph.nodes.Where(node => node.Walkable).ToList(), 1);

It makes since since GridNode inherits from GraphNode, but I’m not really sure what’s going on. Maybe an older version of the project?

Anyways, please help me extract a single random point from a grid graph.


I think your code just misses a cast and to extract the first index from the list that is returned (I haven’t tested it, but I think this should work)

var gridGraph =;
var nodes = gridGraph.nodes.Where(node => node.Walkable).OfType<GraphNode>().ToList();
pathTarget.position = PathUtilities.GetPointsOnNodes(nodes, 1)[0];

For a faster solution you can use:

var gridGraph =;
var randomNode = gridGraph.nodes[Random.Range(0, gridGraph.nodes.Length)];
pathTarget.position = randomNode.RandomPointOnSurface();

You might also be interested in this tutorial on making a wandering ai (linking to the beta docs as this tutorial has not been added to the release docs yet):

Excellent! Yep, just wasn’t casting it… Thanks for answering this… Feel kind of silly now…