Working with nodes in grid graphs

Hey,
Right now I’m trying to figure out how exactly one is supposed to handle nodes in the gridgraph. I have a bridge prefab which I want to spawn after the game starts. Instead of just updating the grid, I want to create new grid nodes based on the position of some empties which I placed manually all over the bridge.

So I create the nodes like this :
NavGraph.CreateNodes(NumberOfEmpties)
and scan the graph.

and then I go through the list and set the node.position to the position of the empties. Then I set node.walkable to true on all of them and connect them via node.AddConnection() (in both directions) to the next nodes. I also connect the nodes at the end of the bridge to the normal grid nodes.
Now the grid looks just like I want it to, everything’s nicely connected. But when I calculate a path it completely ignores the additional changes, and if I scan the graph again the changes I made disappear.

What am I doing wrong here?

Best,
kiriri

Hi

Grid graphs assume their internal structure is a grid. If you start creating nodes in other places, it will behave weirdly.

What you should do is to create a new Point Graph and use those nodes.
You can create a point graph which uses your entities as node positions, then scan the graph to read those node positions and create the nodes. Then you can loop through the nodes and set the connections which are required.
Note that AddConnection is one way, you will need to add the connection the other way around as well.