Precalculating Paths in the Editor, and storing them for later use

Currently working on a pathfinding solution for my TD system. I have a custom editor that allows me to place manual points on the grid and link them up. For each of these links I’d like to use A* to determine if the path between said points is valid, and if it is, just recycling that precalculated path for any AI currently on the route. Then if any obstacles get placed on the route then only one section of the maps pathfinding needs to be recalculated.

However, I’m having difficulty getting a Path to calculate outside of play mode.

I am calling ABPath.Construct seems to only result in a path with a length of 0, and the Complete delegate never seems to be called.

I saw in previous post there was something called Path Calling? But the links to those features just lead to a 404.

Is the pathfinding not available outside of playmode? Or is there some solution I’m not accounting for?

image

understandably this system of mine is a bit over-engineered, but I’d like to see If I can get it working.

You still have to call into the system to search for the resulting path, only constructing a path with start and end doesn’t do that automatically.

Awesome, thanks a bunch. Just added the line “AstarPath.StartPath(~)” Fixed it!

Now I need to figure out how to save the Path data, Since it doesn’t appear to be serialized.

Should I store the vector path or is there a better method to saving the path

I don’t know what you want to do with the path, but by default i would assume that there’s not much value in storing the Path object itself, other than to postprocess it via modifiers, and even then i’m not sure if that’s even fully possible if it is reconstructed later on. But that assumes that you even need multiple different ways to process the same path and can’t just do that once and store the result alone.
In the end, what you ‘should’ do depends on what you ‘want’ to do.

you can save the VectorPath, it is a list of Vector3, and then reconstruct it from ABPath.FakePath if that is required.