Hi. I’m trying to make a custom agent that moves through my game using a path previously calculated by a Seeker. The character has a target that it needs to reach, and through the behavior designer tree we update how often it needs to calculate a path and traverse it through the different elements of the game (with custom traversing logic set in the behavior tree).
Since we need to handle the custom logic internally after reaching a link, we simply calculate when the Seeker’s current node is a link and then we trigger it. OnTraverseOffMeshLink we simply trigger a specific behavior tree event and handle all movement logic through there.
Right now I’m having some problems in properly detecting all viable OffMeshLinks in a path, as it seems that some times we get more than needed and the Seeker tries to use the same one twice. On the Seeker’s OnPathComplete we iterate over all nodes in the path and add those that are LinkNode to a queue. Then, as the Seeker moves through the calculated path we check if the next node is a link based on distance and we trigger it.
As I’ve said before, since the path sometimes includes the same link twice and one time after the other, even if we dequeue the first link, the second one gets triggered incorrectly. Is there a better way to handle traversing links on a path calculated by the Seeker? Does this happen because NodeLink2 creates two nodes at start and end positions and then connects through those?
Thank you for your time and help in advance 
- A* version: 5.3.3
- Unity version: 6000.0.36f1
Hi
I would recommend using the Funnel.SplitIntoParts method. It takes node sequence and splits it into off mesh links and normal paths.
See SplitIntoParts - A* Pathfinding Project
Thank you for such a fast answer!
I’m giving a look at Funnel.SplitIntoParts and I’ve seen that I can then check each node to see what’s a link and what’s the normal path. Now my problem lies in that I do not know how to trigger each link when required.
As I said in my previous post, OnPathComplete we store in a queue the LinkNodes so that we can then trigger their OnTraverseOffMeshLink. We need to do this because each link has a tag and we use their tags to handle different behaviours in our tree. If instead of using the LinkNodes we used Funnel.PathParts, how would I then know which type of link I’m interacting with?
Am I missing something about how to use the SplitIntoParts method? Do I maybe keep both the LinkNodes queue and the PathParts to then check every time we trigger one to know to which one they’re connected?
Once again, thank you for the help and fast responses! You’ve been a great help and I really appreciate tool developers like you.
1 Like
I want to add into my previous post, since I’ve already found how to deal with my issue.
Looking through the forum I found How can I detect the direction a link is being travelled? - Beginner Questions - Support Forum. In the post it’s clearly explained how to iterate through the PathParts and cast the proper parts into NodeLinks if needed.
I’ve just adapted my code based on that response and it seems to work perfectly. Thank you once again for the help!
1 Like