Generate path from existing nodes and connections

I have an existing dataset of nodes and their connections to each other. I want to find the shortest path from one node to another at runtime, without any manipulation of the scene, only through scripting. How can I achieve this?

I can now accomplish this with an editor script, but i’m having some issues when playing. I am parsing my nodes and connections, and creating node objects and adding a PointNode to the point graph, then adding connections dynamically. In the editor (not playing), it seems to work as it displays all the nodes and the correct connections between then.

But when I hit “Play”, everything screws up and it either removes all connections, or if I do my dynamic adding at startup instead of in the editor, all the connections become wrong. Do you have any tips for why it’s messing up at play time when it works in the editor?

Hi

Graph data is not serialized in the editor, only settings are (unless you explicitly save it in the Save & Load tab) so if you generate it when not playing it will be cleared when starting the game.

I am not sure why it doesn’t work when you try to do it at startup. Maybe you could post a screenshot or some code?

Another option is to create your own graph type, this allows you to customize the behaviour a lot more, but you will loose some features from the PointGraph (such as a more optimized GetNearest method). See http://arongranberg.com/astar/docs/writing-graph-generators.php