Get OffMeshLinks

Hey, I’m busy setting up a system that needs access to all of the OffMeshLinks in a scene, currently I simply use FindObjectsOfType to return a list of the NodeLink2 components, however what I really need is references to actual nodes (I think the LinkNode type).

In the A* docs I’ve found information on the OffMeshLinks class, which it describes as a manager that tracks all off-mesh links, though I cannot work out where/how to access this.

Could anyone point me in the right direction please?

Hi

You can access that manager via AstarPath.offMeshLinks.

However, it only allows you to get the nearest link to a point.

You can also iterate through all link nodes via

AstarPath.active.data.linkGraph.GetNodes(node => {
    var linkNode = (LinkNode)node;
    // linkNode.linkConcrete.startNodes
    // linkNode.linkConcrete.endNodes
});
1 Like

Wonderful, thank you Aron, I think this may be exactly what I need. Thanks for replying so quickly too!