Replace AstarPath.active.Scan()

Hi, I’m using 4.2.15 (pro version) with a grid graph setup. So far I’ve used AstarPath.active.Scan() with good results. To achieve perfect results, I’ve then started to scan my entire map tile by tile and set each node manually (node.Walkable = true/false). Now I’m thinking I don’t really need to use AstarPath.active.Scan() anymore, as I’m scanning the whole graph for a second time anyway, but if I remove that line, I get:

NullReferenceException: Object reference not set to an instance of an object
Pathfinding.GridGraph.GetNode (System.Int32 x, System.Int32 z)

It seems AstarPath.active.Scan() is doing more than just scan the area. How could I get this to work without using AstarPath.active.Scan() and thereby avoid scanning twice?

Hi

Scan needs to be called to create all the nodes of the graph.
If you disable most options in the grid graph like ‘height testing’ and ‘collision testing’ and erosion the scan will be very fast and not do much other than just creating the nodes.

Thanks Aron. I can set erosions to 0 and disable collision testing and it all works fine. As soon as I disable height testing, I run into trouble. I seem to be getting nodes and all, but can’t get a path. In the scene window, the nodes show, but somehow in a lighter colour.

Height testing enabled, all good:

Height testing disabled, path failed:

Hi

It looks like the height testing ensured that the nodes were positioned on your level. When disabled it looks like the nodes are further down.
You might need to modify the y coordinate of the center of the graph.

Thanks Aron, that makes perfect sense. For some reason I always thought of the graph as a 2D construct, not 3D. I’ll just leave it set at the height testing, which works perfectly fine. Once again thank you!