Make agent move using roads when specified


First i would like to point out that i use A* Free version. For now, at least.

What i am trying to do is to make my agent move on roads when they are:

  1. Got a specific command to do so, which means their normal behavior shouldn’t include road-moving
  2. When using a road will actually shorten time needed for travel.

The first problems i’ve encountered while doing this is that agents will try cut the path when modifiers is used. What i need is agents modifying the part of path that is not on the road, while not editing road-part of it at all.
The other problem is that i basically need the agents to use two graphs when 1) is true. I guess making all of this into one graph is not an option since i need this functionality be turned off by default. Which leads to question: how do i use two graphs at once? Or how do i avoid this to begin with?

Currently my roads is basically a point graph with custom generator, and all other terrain is covered with grid graph(will probably change it to navmesh or recast if i decide to upgrade to Pro later, but for now that’s how it is)


Do agents on roads need to follow lanes, intersections etc? Or is it just a movement buff when the agent is on the road (similar to Don’t Starve). If so I’d suggest removing the point graph, and instead apply a tag on the road, and set the penalty of the world to a much higher value. This way agents will prioritize roads.

They do need to follow the lanes, yes. The agents is vehicles, though they dont really need to handle complex traffic rules - only following lanes while staying on the road, pretty much.

And since i don’t need the usage of roads(and their speed boost too) all the time i’m not sure if deleting point graph is good idea. The desired behavior is “Ignore the roads and dont use their boost unless said otherwise (when command is given)”

My idea of solving this was to first make path on grid without roads and then compare it to the another complex one where roads is used by combining several sub-paths using FakePath (Like: Me — Closest road point1 — Point on road closest to destination ---- destination).
But i didnt tried that yet, plus amount of path calculations would be twice more heavier, which is problematic even if i somehow do this in jobs…