Starting pahfinding from PointGraph to RecastGraph

We have 2 graphs overlapping each other and we would like to start a pathfinding from the PointGraph and ending it on the RecastGrraph. We have “one way” links between the 2 Graphes. Each research seems to use a start position (not a node), so the question is how to be sure it will first use the PointGraph ? Could the start point be in the middle of 2 point nodes of the Graph ? Traveling on the PointGraph must have a very low cost compared to the recastGaph, so can we manage this using the costFactor ?
If chaining both graphes is complex, we could probably start pathfinding on the PointGraph, estimate the most interesting point to leave it and then start on RecastGraph from this point. But we are not sure to know how to recast only on a Graph.

Thank you in advance for your tips


Regarding the links, I have a similar question : how to be sure that the start point is linked to the PointGraph and the end to the RecastGraph ? NodeLink2 is only taking positions.



This is not possible directly. However, you could manually link the point graph and the recast graph using the GraphNode.Connect method. These wouldn’t be off-mesh links with metadata (like the ones the NodeLink2 creates), but they would connect the graphs.

It’s also not possible to make a path search start on one graph, and then end up on another out of the box.
However, you could subclass the PathNNConstraint class, and supply your own variant to your path in the path.nnConstraint field. The path will first use it to search for a valid start node, then it will call the PathNNConstraint.SetStart method, and then it will search for the end node. This means you could change the graph mask when the SetStart method is called.

See PathNNConstraint - A* Pathfinding Project
See GraphNode - A* Pathfinding Project

Yesterday, I already tried what you mentionned here, ie GraphNode.Connect and the pathfinding was able to begin from my PointGraph, to find a link and so to continue on the ReacastGraph. I am not sure, if it was the shortest path because it leaves the PointGraph quicly I think (perhaps when reaching the first link crossed, will have to check).
In fact, I have different constraints on both Graph, and I would like to favorise the PointGraph (moving must be easier on it and so the pathfinding has to continue on it until reaching the closest exit from the final target : closest means closest on the RecastGraph and not distance on the fly like it seems to work on PointGraph).
So, the question is : do you think that the pathfinding can give good results there or do I have to follow your tips (subclassing PathNNConstraint) ?
I was wondering if I could not simply find the closest endpoint on PointGraph using a MultiTargetPath from my final target (to all PointNodes positions of the PointGraph) and then search again from my start point to this closest endpoint using only PointGraph research in this case. A am not sure if the MultiTargetPath limitations (ie targets count) could be an issue. I hope it was clear enough and make sense.


If that’s what you want, then maybe you want to search only on the point graph first, and then when the agent has reached the end of that path, switch to the recast graph (only). That way it will first move to the closest point it can reach on the point graph, and then move along the recast graph.

PointGaph seems to stop at the closest straight distance to the target which is not the clostest using a pathfinding on the ReacastGaph. This is why I was thinking first to use a MultiTargetPath to determine the closest endpoint, and then search on PointGraph. It will separate both path and I will have to merge them so. Not sure to know if MultiTargetPath will support thousand of targets, perhaps better to use several MultiTargetPath with a batch of dots…

A better solution could be to use

var path = ABPath.Construct(startPoint, startPoint);
path.endingCondition = new MyCustomEndingCondition();
path.heuristic = Heuristic.None;

where MyCustomEndingCondition does something like:

public class MyCustomEndingCondition : PathEndingCondition {
	public MyCustomEndingCondition (ABPath p) {
		path = p;

	/** Has the ending condition been fulfilled.
	 * \param node The current node.
	 * \param H Heuristic score. See Pathfinding.PathNode.H
	 * \param G Cost to reach this node. See Pathfinding.PathNode.G
	 * This is per default the same as asking if \a node == \a p.endNode */
	public override bool TargetFound (GraphNode node, uint H, uint G) {
		return node is PointNode;

Thank you for your idea. But it supposes that there are connexions between both Graph. My one way links were defined in the other direction (ie from PointGraph to RecastGraph to avoid any other issue when Pathfinding on mesh). I have noticed that Funnel modifier was throwing an exception when facing on a PointNode, so better to avoid this use case. But correct me, using Tag could help here, I could create links (RecastGraph to PointGraph) and use your proposal (ie MyCustomEndingCondition) using tags for both graphs. Once closest PointNode is found, I could then use only the ReactGraph tag to search only on it (and skip any PointNode) ? Does it make sense ?


I tried to add connection between graphs like this :

var node1 = pointgraph.GetNearest(pos, NNConstraint.None).node;
var node2 = recastgraph.GetNearest(pos, NNConstraint.None).node;

uint cost = 0;
GraphNode.Connect(node1, node2, cost, OffMeshLinks.Directionality.TwoWay);

But I can not see the links displayed on the graph and MyEndCondition failed

I tried to create a NodeLink2 instead and there I can see the link on the graph, and MyEndCondition seems to find a LinkNode which is a PointNode so that worked.

What is wrong using the GaphNode.Connect ?