I saw this post and tried to make use of them to connect my level’s several grid graphs. And I was almost successful, right until I tried to make NPCs to do more than just walk between grids with these nodes.
Documentation refers to some example scenes to check how these nodes can be detected in a path, but those are, I’m guessing, Pro-only, since I was unable to find them. @aron_granberg, would it be possible to post a snippet of the relevant code that distinguishes the NodeLink2’s, please?
I’m basically using an entirely custom character move script, so suppose my function for the character moving received an Astar Path object with a calculated path - what would be next step? Or, is the necessary code happen before querying
The first solution I tried is to test if the node in the current path sequence index is connected to a NodeLink, via
NodeLink2.GetNodeLink(path.path[currentNodeIndex]), but I quickly realized that with this approach I’m basically unable to use any path modificators since then the length of
vectorPath does not match the amount of nodes in
So next I tried a rather hackier way by iterating through all nodes in
path and collecting all NodeLinks that were found before beginning movement, and iteratively testing whichever is closest and within the acceptance range during the movement, but this proved to be rather buggy and unreliable - sometimes node reacts to NPC, sometimes I guess NPC walks by too far away from the node to detect it, and sometimes even several
NodeLink test true if they’re close together.
I suspect I need to somehow map the
NodeLink to indexes in the
vectorPath (so that I can check if the current vector index NPC is moving towards has any
NodeLink associated with), but IDK how to project them onto the modified path.
My third last resort idea is to construct the path iteratively - first constructing the path as usual, and then breaking it into node chunks from start, to any
NodeLink, and from
NodeLink to target, and then generate new path for each chunk and go through them sequentially, but I’m unsure that’s an efficient way to do things (It amounts to at least 3 path requests instead of just 1…). On the plus side, NPCs will always go precisely through all the nodelinks no matter the path postprocessing, though…
Any help would be appreciated!
…Though node links already helped me immensely - thanks to the
NodeLink2.GetNodeLink() I was able to hack my way into the pathfinding algorithm and inject additional data and conditions for deciding if a node is walkable or not into the
TraversalProvider, achieving a sort of dynamic update of certain node grid paths according to the specific NPC’s travel settings (Not all NPC’s are immune to fall damage all the time, for instance, so those should avoid dropping off the ledges).