A* Pathfinding Project

How to get GridGraph coordinates from a world space point?


I have a position in world space and I need the corresponding GridGraph coordinates.

The closest I can find is MyGridGraph.GetNearest(WorldVector3).node. That gets me the correct node, but I can’t find any way to get the grid coordinates from the node.

Right now I’m calculating it manually, which works, but seems like a really clunky way to get to data that must already be in there somewhere…

Is there something like a Node.GridCoordinates or GridGraph.GetCoordinates(Node)?




You can use (node as GridNodeBase).XCoordinateInGrid and (node as GridNodeBase).ZCoordinateInGrid.

See https://arongranberg.com/astar/docs/gridnodebase.html#XCoordinateInGrid


Perfect! Thanks so much. :slight_smile: