Support Forum

Moving or removing a node from Recast Graph

Hi!

Is there any way to remove or move a node from a recast graph so that it wont be included in a GetContours call?

I am using the Automatic node link placer which makes use of the GetContours method to find the edges for the links.

After generating the graph (but before running the link placer) I am checking nodes and marking some nodes as “invalid”. I’ve tried setting Walkable to false, but it doesn’t affect whether they are included in the contours. Directly changing node.position doesn’t seem to do anything.

Maybe it would be a better approach to just tap into the generation code and intercept the node creation with my custom conditions before it is even created? Going to dive into that for a bit :slight_smile:

Hi

Have you checked out the RecastMeshObj component? It allows you to make a specific surface unwalkable.

I have thought about that, but haven’t tried yet since that would require me to add the component to the object at runtime after I’ve identified it as “problematic”.

I should have mentioned in the OP but my levels are procedurally generated and I don’t know beforehand which objects will need the component.

Basically what I’m doing is I’m checking if the nodes generated are inside a mesh. The code for that works great, and I’m identifying all nodes that are generated inside meshes.

I cannot use the “walkable height” option because the height of these meshes vary greatly and some of the meshes will inevitably be very tall, at the same time as some parts of the level will have a very low ceiling (think caves). I also need the top of these objects to be walkable.

Hi

Are these objects made of convex colliders by any chance (i.e. any colliders except not non-convex mesh colliders)?

Nope, they are non-convex mesh colliders.

Ok, so the way I solved this isn’t really releated to Astar, but rather the Automatic node link placer tool, but I’ll explain it here anyway.

In the CalcEdges step, just after doing the GetContours call, I’m just looping through the edgepoints and doing my verification there.

Doing my verification in the CheckPlacePos or CheckPlacePosHorizontal step was too late, and would result in important links being skipped because my verification denied placing links in those positions. Basically it was placing links from valid origins to invalid destinations, which then would be removed by my verification, preventing those valid origins being used for any valid destinations.

Doing it in the CalcEdges step allowed me to get the invalid edgepoints out of the way early, leaving room for links starting in the same origin but with a valid destination.

1 Like