Support Forum

Can't get Nodelink3 to work

I am having problems making RichAI and Nodelink3 work linking a mesh added with NavmeshAdd.

I have a player building system and I update the a recast graph for the building mesh using NavmeshCut and NavmeshAdd. I create a moat around the building with a larger cut than the building size, then add the new building graph mesh with Navmeshadd, finally, I link the new mesh with the terrain using Nodelink3 and apply using the code snippet below.

I am using Opsives Ultimate Character Controller. Which sets IAstarAI.canMove = false. The controller calls IAstarAI.MovementUpdate to get the location to move to and controls the agents movement directly.

This all works great, the path is calculated correctly using the nodelink, except RichAI.MovmentUpdate does not appear to return movements along the Nodelink3. Sometimes the agent jumps onto the new building mesh and when it does navigates correctly

I have tried placing the nodelinks at the edge of the node and then in the center. This video shows the nodelinks in the center of the node. The big white line is the agent path. But as you can see, the agent just stops at the edge of the terrains recast graph, when it should follow the nodelink.

One other thing to note, I delay adding the Nodelinks, until pathfinding has processed the navmeshCut and navmeshAdd. Also, the nodelinks are in the Point Graph and the agent seeker ahs traversable graphs set to everything.

Is there any way to debug nodelinks? Or other possible reasons the nodelinks aren’t working?

// Called on NavmeshCut and NavmeshAdd
			meshAdd.RebuildMesh();
			meshAdd.ForceUpdate();

// Called for new links
            AstarPath.active.AddWorkItem(() => {
                foreach (var link in m_links)
                {
                    NodeLink3 nl = link.gameObject.GetComponent<NodeLink3>();
                    if (nl != null)
                        nl.Apply(true);
                    //nl.Apply();
                }
            });

I tested the bot from Example4_Recast_Navmesh2 in my scene. I thought perhaps I needed to handle movement over the off mesh link. To start with I put a breakpoint on the first line of TraverseOffMeshLink, but the onTraverseOffMeshLink event does not fire when the bot reaches the NodeLink3 link. It behaves the same as my agent.

I am guessing that the NodeLink3 has not been properly established in the scene. Is there something else besides calling NodeLink3.Apply(true) that needs to run to complete setup?

I tried NodeLink2 and this does trigger the onTraverseOffMeshLink event. But because I haven’t written the traverse code, it just snaps the agent to the end of the link, but it does work.

This video shows agent stopping NodeLink3

This video shows agent stopping at Nodelink3, but with terrain turned off so you can see gizmos

The funneling support NodeLink3 provides would have been nice, but I think I am missing a step in how to add NodeLink3 at runtime and so I am giving up for now.

NodeLink2 works well. The limitation of NodeLink2 is that there is only a single path the agent will follow and so if I have multiple agents trying to enter a building, they will line up single file. I was hoping NodeLink3 would allow them to group up around a building entrance if the door is closed and try to bash it down.

I tried creating welds between the base mesh and the terrain with another NavmeshAdd, I made sure the weld mesh vertex positions matched the terrain and building mesh. This works exceptional well.

@Aron, you have been discouraging about doing this in a few posts. But your code handles this brilliantly and it eliminates the problem of off mesh movement.

Hi

Sorry for the late reply, I’ve been sick these last few weeks.

It looks like you managed to solve everything! I’m glad it works for you :slight_smile:

I have. It does work well, but it’s very fiddly and you have to make sure to match vertex positions exactly. So it’s that easily used. But when it works, it works well.

1 Like