Support Forum

Best way to get a duplicate of a graph and assign it to a seperate graph layer/index?

Hi have been customizing this for our game.

Just wanted to know the best way to create a duplicate of a grid graph eg
hard copy[1] to[3] (at runtime/ level load);

So i can then add the special connections to the new instance and choose which grid the ai should use based upon its capabilities.

      void ConnectJumpSpot(int graphNumber)
                    var graph =[graphNumber];
                    GraphNode startNode = graph.GetNearest(from, NNConstraint.Default).node;
                    GraphNode toNode = graph.GetNearest(to, NNConstraint.Default).node;
                    startNode.AddSpecialAction(GraphNodeSpecialAction.JumpForwards, jumpPoint);
                    startNode.AddConnection(toNode, 0);
                    jumpPoint.FromNode = startNode;
                    toNode.AddSpecialAction(GraphNodeSpecialAction.JumpBackwards, jumpPoint);
                    toNode.AddConnection(startNode, 0);
                    jumpPoint.ToNode = toNode;

This is for a pro layered grid graph.
Have already edited the base code to work with the special actions in aipath.


1 Like


It’s not super easy to duplicate a graph unfortunately. The easiest way I think is to serialize the graph to a file and then load it using See

Excellent, should be easy to get a byte representation of a graph and load it into another index with these functions. Cheers.