Inherit from GridGraph


I’m searching to inherit from GridGraph in order to keep its algorithm implementation (connections builder and path calculation) but to provide it the nodes myself (get rid of the raycast/collision part). I’m using a tiles system and want to directly provide it the tiles as nodes.

Unfortunatly, when I tried to implement it, I didn’t find any abstract class separated from the GridGenerator in order to implement the custom graph. The Rule implementation is not a solution either as I can’t modify the tile array size during the rule filtering operation.

What do you think would be the best way to implement this ?

Thank you !


Even if the GridGraph class is not abstract, you can definitely inherit from it. The layered grid graph inherits from the GridGraph.

Thanks for your answer, I’ll inherit from GridGraph, but how can I directly provide the nodes myself (so no Raycasting to find the nodes automatically) while letting the graph do the connections automatically using all the rules you already implemented into it?

We already have a 2 dimensional array that holds all our tiles (and thus the nodes) that’s already precomputed, so we don’t want the graph to do the raycasting to find them

The ScanInternal(bool) method where you can pass the nodes seems to also override the connections-building phase, so if I pass the nodes directly I won’t get the connections automatically made.

Thank you!


Btw, is it not easier for you to not override the grid graph, and instead do something like:

var gg =;
gg.SetDimensions(200, 200, gg.nodeSize);
gg.rules.AddRule(new MyCustomGridGraphRule());
gg.collision.heightCheck = false;

in which your custom rule just copies your already existing data.
Or you could even use the texture rule to copy data from a texture. See RuleTexture - A* Pathfinding Project

Thank you for your answer!