Can I generate a graph in Unity on a terrain to be used in a C++ project outside Unity?

I’m working on a C++ project(mapmaking project with custom triggers for NPC’s) where I am not using the unity engine but the terrain (and all the procedural generated prefabs) are made in the unity engine. The terrain will be randomly generated each time (also all the prefabs).

So I have:
The terrain with all the obstacles and I (can) generate a navmesh from Unity if needed (or better yet from A*).

Example:
I have a constantly updated object position(x,y,z) in my program (this will have the same world coordinates as the nodes use).
I want to set a target (x,y,z) in the world and instruct the object to go there without getting stuck.

The easiest I thought would be:
I need a web or graph that my C++ program can use (standalone). It doesn’t need to care about the map, only its current position, where the target is and which nodes to use to get there the fasest.

The nodes do not need to go to the target. As long as a node is sufficiently close by i can instruct by code to stop using the node webwalking system and go straight from the closest node to the target.

Would it be possible to get each ‘center’ of a hexagon and export this data in json or an array or anything so I can use it in my C++ project?

I mean, worst case i can write a C# script which finds each center of the hexagons provided by A* and writes them to an array.

Would anybody be able to help me out or send me in the right direction?

Hi

You can read all the graph data that this package generates. See this page: Accessing graph data - A* Pathfinding Project

Thanks for the fast reply! I got it!

I don’t think I can use your code or pathfinding in my C++ project so i’ll have to build my own or atleast try something…
Would it be correct to approach this from a 2D pathfinding point of view? (i’m only keeping the nodes that are walkable (this in theory should provide me with a node map that doesn’t care about height right? If the nodes are neighbours and all the nodes are walkable, I should be able to just approach this from a 2D point of view and say take node x,y, then continue through those nodes until i reach the target node right?)

Right now I am finding 76 372 walkable nodes out of the 160 0000 total nodes.
I am adding these to a list.
I can see their position with node.position (vector3 converted).
But should I use this or should I use a Node(x,y) representation to traverse it?
(if so about the 2D, how do I get the x and y from the node itself?)

Sorry for perhaps the dumb question :grimacing: