How to add forces to nodes in a GridGraph for obstacle avoidance

I am using pathfinding in a 2d game with AI spaceships and walls as obstacles. I want to add force data in nodes that are close to obstacles to have better steering of my AI ships when following paths.

Here is an illustration of what I want:

I found EdgeNode on GridNode but this is not implemented yet.

I would like a performant way to calculate the forces. My guess is that I want to start with all the edge nodes and check their connections, and when all the edge nodes have been calculated I could go to all the connections from there and do the same thing again, and again.

Is there a smarter way of calculating this maybe ?

Hi

Essentially what you want to do is to calculate the grassfire transform of the graph and also store which unwalkable node was the closest node to every walkable node. There is no built in way to do this, but you can implement it yourself relatively easily.

You can use the pseudo code for the grassfire transform and you can get if a node is walkable or not using

 var gg = AstarPath.active.astarData.gridGraph;
 var nodes = gg.nodes; // width*depth
 int x = 5;
 int z = 10;
 Debug.Log("Is node at (5,10) walkable? " + nodes[x + z*gg.width].Walkable);