NodeLink3 Error / Should I even be using this?

Hi Aron.

I’ve been having issues with properly using node links in our recast graph.

Basically, i have setup a Node2Link between different rooms in our graph, so that the agents will traverse through the door in a straight line, and not try and funnel improperly, since when we have small doors, the AI gets stuck if not walking the right line.

Now, the issue has been for the most part the fact that when you cache the graph, the nodes no longer get flagged as rich special (you’ve mentioned before that it was a case you didn’t consider).

After reading this post : Correct usage of NodeLink, NodeLink2, NodeLink3

I thought it might work with Node3Link better. So i changed the nodes around and tried scanning the graphs again.

I got this error (multiple times)

Wait wut!? 0 -0.2162162 ( 152490, -10000, 64325) ( 152390, -10000, 63725) ( 153890, -10000, 64225) ( 153890, -10000, 64325)
TODO, fix this error
UnityEngine.Debug:LogError(Object)
Pathfinding.NodeLink3:Apply(Boolean) (at Assets/AstarPathfindingProject/Core/Misc/NodeLink3.cs:288)

Can you comment on the best way to achieve the desired functionality for our case?
Can you explain why this error happens?

Thanks

Yeah… I need to fix that at some point. It is very tricky to make it work properly with serialization however.

Regarding NodeLink3.
I have in a separate branch of the project investigated that error and if I remember correctly, that error was logged when two triangles only shared a single vertex/point, not a segment.
Here is an experimental update of the script: http://pastebin.com/8u1PzAKj
Note that that version contains a few hacks because I used it for another game project that required some special logic.
Also note that NodeLink3 requires a shared edge between the nodes that you link.

However I think the best/easiest solution is to apply the NodeLink2 objects right after loading the graph.
So you would disable all NodeLink2 objects in the scene, then cache the graph data. When the game started, it would first load the cached data, and then you would activate all the NodeLink2 components and add the correct links.
I think that will work anyway, I am not totally sure.

@aron_granberg

Yeah, not so sure Link3 work, since there it is most likely that those links cross over tiles, so there will be no shared egde.

So you would disable all NodeLink2 objects in the scene, then cache the graph data. When the game started, it would first load the cached data, and then you would activate all the NodeLink2 components and add the correct links.

I tried loading nodes in like the that in the past, and wasn’t able to get the links added properly to the graph.

Can you give me a sample code of how to properly apply the links after the cache is loaded?

Hi

Hm… I really need to fix these links so that they work properly. Sorry about the trouble.

I think that to get it to work as it is right now, right after you have loaded everything you will need to on all links call

myLink.OnPostScan ()

Alternatively you could probably override the OnPostCacheLoad method in the NodeLink2 class and use that to call OnPostScan which will probably work as well.

Thanks Aron.

Overriding OnPostCacheLoad() and calling OnPostScan() in it did the trick perfectly.

1 Like