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?