Combining PointGraph and GridGraph - terrain and roads

Here’s what I’m trying to achieve: I have a 2D map with a GridGraph + texture which is used to get node penalty (mountain areas, lakes, etc.). This works ok. Now I’d like to use a PointGraph to describe the roads on the map as I don’t think the texture will be accurate enough for this - I’d need a very detailed GridGraph/texture.

I have a test scene with both a GridGraph and PointGraph, prioritized. However, when the path is searched, it seems that A* simply selects the graph from which it finds the closest start node? I’d basically like to achieve a mixed search between the two graphs, i.e. use roads when possible, otherwise take a shortcut through the terrain. I assume this isn’t possible without some additional scripting?

I never did it, but I think that you can create points that connect two graphs.

But I think that the best solution is use tags.

Hi

That is a bit tricky to achieve. The problem is that it is very hard to know when the road is “close enough”, and you need to link it together with the grid graph which is also tricky. However I do know of games which has successfully added roads with lower penalty using a grid graph (check out Folk Tale on Steam). That world was very large so in the end they ended up switching to using a navmesh instead, but the current build on Steam uses grid graphs and it works fine.

A bit of necromancy.

Basically, I have precisely the same problem: big world (upwards of 2000x2000 game units), coarse GridGraph for general terrain and very precise PointGraph for roads. Both work just fine separately, but I would really like to be able to make Paths that use both.

So far, it indeed looks like that pathfinding is done with graph which has a closest node. Is that correct?

What are my options to make a path through two intersecting graphs?
First of all, is it even feasible? Or I’m looking at rewriting some core A* functionality here?

If it’s not that crazy, what classes I should be looking at first? Graph? Path?

I’m not entirely understanding what is meant by

you need to link it together with the grid graph
Like, I should estabilish some kind of connections between the nodes of GridGraph and PointGraph?

Would subclassing some kind of my own Graph which will combine both types of Nodes be easier?

Hi

The only approach I see that might work is to, after the scan has been completed, loop through all nodes in the point graph and connect those nodes to a few nearby grid nodes (using node.AddConnection).
Make sure this is done when it is safe to update the graph, e.g by calling AstarPath.RegisterSafeUpdate.