How can I detect the direction a link is being travelled?

  • A* version: 5.3.3
  • Unity version: 2022.3.52f1

I need to do my own postprocessing on a path and would like as much info about the links as possible. I’m able to find a refernce to the links, but besides the position I haven’t found an obvious way to get the direction that a TwoWay directional NodeLink2 is being travelled. I could do an approximate position comparison, but it feels like there should be a way to just get it out of the LinkNode object.

In the path’s GraphNodes list, I can see 2 entries for each Link, which is in the order of the calculated path. From inside there I can figure out a link to the GameObject and/or NodeLink2 that was used. But I’d like to find out reliably whether the first encountered point (e.g. GameObject or Transform) is the start or the end of the link.
image

Hi

I would recommend using

var parts = Funnel.SplitIntoParts(path);

foreach (var part in parts) {
    if (part.type = PartType.OffMeshLink) {
        var linkNode = path.path[part.startIndex] as LinkNode;
        var tracer = linkNode.linkConcrete.GetTracer(linkNode);
        Debug.Log(tracer.isReverse);
    }
}
1 Like