Issues with runtime nodes & scanning the full grid graph

I am trying to create a road system for my RTS project, experimenting with A* Grid Graph.

I have a very simple plane mesh that represents a road and has a tag of “Road”. I instantiate these on runtime and scan the graph after instantiating each segment as following:

// Use colliders bounds to scan graph around it
var guo = new GraphUpdateObject(bounds);
guo.updatePhysics = true;
guo.modifyTag = true;
guo.setTag = tag;

AstarPath.active.UpdateGraphs(guo, 2f);

This works well for all newly instantiated segments, as you can see in the screenshot - blue overlay over road segments means there are connection on the node. When actors actually do “walk” over them, they increase in speed as its supposed to be and is handled by other parts of the code.
Although, if I scan the full graph via the script or inspector (by clicking the Scan button), all the road node connections vanish, and there is no way of returning them back, without engineering a way to do something similar as above pointed code. I wonder why is that? How can I ensure these are preserved?

  • Road segments in the screenshot without blue overlay are the ones that lost the connections after the full scan of the graph. The ones with actual blue overlay are newer instantiated segments without scanning the full graph.

Question 2 - Unrelated to above issue:
The blue cubes you see in the middle of the each road segment are coming straight from the point graph that I added to experiment the connections between segments using it. As you might already guess, the connection lines are totally missing and there is no way for me to check if these are connected or not without running IsValidConnection() or similar. I am using a 4.2.17 version of the package.

This is not related to the initial issue, and I tried changing the coloring in the settings to trigger them again, but no luck.

I meant to use Point Graph to create a versatile road system that will be “smart” enough to go around obstacles in certain layers. Though I guess I can totally drop this and rely entirely on ABPath to construct the path and get the nodes back?

Hi

Indeed, when you scan a graph, it will be recalculated from scratch. So any modifications done to it will be lost.
I would instead recommend that you put your roads on a special layer, and then use the PerLayerModifications grid graph rule: RulePerLayerModifications - A* Pathfinding Project. Then you can recalculate the graph in any part of the world, or recalculate it completely from scratch, and it will pick up on your road tiles.

Not quite sure what you are asking for in your second question.

1 Like

Thanks for the answer Aron. Would the RulePerLayerModification rule be part of the newer 5.0+ version of the package?

As stated, I am using the older 4.2.17 version of the package and I don’t see the option of adding such rules.

Yes, it’s only part of 5.0 (and some 4.3.x beta releases).

1 Like