Giving a high penalty to some nodes in navmesh graph by scripting

Hello, I need to prevent my agents from going to close from obstacles.
I can create a navmesh whose holes are larger than obstacles, but for complex geometries is quite difficult and requires a lot of time.
Using recast can be an option but I do not use character controller for my agents ( they are simple rigid bodies) and I don’t know if the recast can work with them (actually i’m using the free version but i’m considering to switch to pro).

I then thought, to change the penalty of the nodes with are closer than a target distance to the obstacles.
So things I need to do are:

  • cycle over all graph node
  • check if an obstacle is close (i know how to do this given the node position)
  • then set its new penalty.
    I need to do this only when the application starts up and the graph is loaded, so in preprocessing not in runtime.
    My problem is that the code related to the update graph is quite complex and I don’t know how can I integrate the code I’m writing with that. I saw that all samples using graph-update are developed using a grid-graph, and the update is done a selected region, so I think I would need to write another function to update graph instead of using graph-update.

Is that all a good idea or are there any better ideas on how to solve this problem?
Thanks a lot for the help.

For navmeshes (assuming you do not use the term navmesh for grid graphs), making nodes unwalkable based on their proximity to obstacles will not work at all. The reason is that navmeshes contain very large triangles so if you marked the nodes adjacent to obstacles as unwalkable, you would very likely block off a whole lot more than just a small distance from the obstacles.

Recast graphs do not care if they are traversed using a rigidbody or a character controller, it only cares about pathfinding. So if you have a movement script that can handle rigidbodies right now, it will probably work for recast graphs as well.