Nodelink2 and NavMeshCut Issues

I am joining two disconnected areas with Link2 component. After a manual scan in editor it joins the two areas properly:

After I run the application, the areas do not appear connected in the editor and the agents are not seeking to the Nodelink2 (there is a jump pad at each end). I have tried disabling cache and enabling scan at startup and results are same.

Astar version 4.2.8. Unity version 2019.2.9.

There are two hacky ways I have found as workarounds but would like to avoid using. Agents seek properly from either end and area joined properly if I do either of these:

  1. Connect the two areas using one additional two way Nodelink. Set the priority value high so agents try not to use.

  2. After a short amount of play time - disable and enable one Nodelink2 component. This fixes all the Nodelinks and things appear ok. I tried doing this in GraphsPostUpdate but does not work (too early?).

I also tried iterating through all Nodelink2 components on Start and calling OnGraphsPostUpdate and this does not help.

Note this is a recast graph and I have tried moving the large platform so it is not over any other path areas. I do have one additional recast graph that I use for checking out of bounds but not for seeking. Results are the same on this one. (This one not visible on my samples)

Thanks.

The Graph Post Update isnt always called. Try switching to something like PostScan

No, it definitely gets called every time for me. (Twice in fact). Also tested that everything that receives the override is responding ok. I have previously tried many things including OnPostScan and OnLatePostScan.

I’ll try recreating this on my side

I was not able to reproduce this issue

I haven’t played around with the Link2 system before, So you’ll have to wait and see @aron_granberg can help you on this one

I have narrowed it down a bit more. It seems NavMeshCuts are causing problems with Nodelink2 connections. Does not matter if one way or two way.

I have made a video to show the problem. Nearby (not overlapping) NavMeshCut will cause Nodelink2 to lose connection. Disable/enable the Nodelink corrects the problem. Moving the NavMeshCut around will provide weird results. Hopefully the video will show better:

https://youtu.be/orsi73GlUy0

1 Like

Here is an ugly hack that fixes things. Not intended for actual use but might shine some light on a clean solution for this. (It works ok but adds an extra NavMeshCut that is not needed - just using for the override).

If I override OnGraphsPostUpdate instead of UsedForCut it does not work.

// Attach this script to each NodeLink2
namespace Pathfinding
{
public class NodeLinkFixer : NavmeshCut
{
NodeLink2 nodeLink;

    protected override void Awake()
    {
        base.Awake();
        nodeLink = GetComponent<NodeLink2>();
    }

    public override void UsedForCut()
    {
        if (this.enabled) {
            nodeLink.enabled = false;
            nodeLink.enabled = true;
        }
    }
}

}

Aron, thanks for the reply. Just to note that I got the email version of your post but it is not appearing in this thread for some reason. Really useful details in that post for others as well.

That explains a lot to me and gives me another option. I will probably go the route of adding a non used 2 way node link for performance.

Hi

Yeah, I noticed you were not using one-way links. So my post was kinda irrelevant.
However I did find some bugs related to node links. Especially in combination with navmesh cuts.
I have uploaded beta version 4.3.8 now which I think should fix your issue.