Separate gameobjects for pathfinding and scene objects?

My goal is a hex grid with 500 x 500 hexes. 250,000 gameobjects.
Currently on my 40 x 40, the same objects are used for pathfinding and visual meshes.
I plan to have a viewport to only display the hexes that are visible. Instantiate hex GO when needed.

I could generate and serialize the graph if I generate all 250,000 at the same time. Don’t even know if Unity can handle it.
These GO would have NO visual information with them.

Is there a design principle to separate the concerns of pathfinding and the view?

Cheers,
Kevin

This solution separates path finding from Unity GameObjects.
It separates path finding from presentation.

Thanks!

Actually, one thing you might need to do is to wrap it in a callback to ensure pathfinding is not running while the nodes are added.

AstarPath.active.AddWorkItem (new AstarWorkItem ( delegate () { // add nodes and generate connections here }, null);

If you do not have this wrapper, an error will probably be logged if you would try to execute the code I wrote in the other answer. This is because it is not safe to modify the graphs at the same time as pathfinding is being processed (maybe in another thread). Wrapping it in a callback will only execute it when the pathfinding threads have stopped and it is safe to run.

Hi

I think the better option at this stage is just to handle the nodes manually. This will be A LOT faster and will not bloat your scene.
The PointGraph has an API for adding nodes during runtime:

`
PointGraph pg = AstarPath.active.astarData.pointGraph;

foreach node that you want to add {
PointNode node = pg.AddNode ( (Int3)position );
}

for each added node {
PointNode node = …
for each node neighbour {
node.AddConnection ( neighbour, (node.position - neighbour.position).costMagnitude );
}
}

// Needed for pathfinding to work
AstarPath.active.FloodFill ();`