Is there a way to store astar points and connections?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By stillinthe90s
:warning: Old Version Published before Godot 3 was released.

Is there a way to store astar points and connections to a file? I.e. to feed the astar node with data instead of having it do the actual calculations?
I’m trying to use astar with a tilemap but calculating everything gets awfully slow even with smaller maps. Loading everything pre-calculated would probably help a lot…

:bust_in_silhouette: Reply From: Sween123

Yes.
You can init the AStar variable one time (add points, connect points)
Later you just update it (add more points, disconnect points, reconnect points)
To save what is in the AStar for later use, create a dictionary to save the points and thier info. Then, you just save the dictionary into a file using to_json().
To load what you have saved, use parse_json() to get the dictionary you saved. Then, iterating the points and init the AStar base on what info each point contains.
(If you don’t know how to save infos into a file: var file = File.new(), file.open(), file.store_line(to_json(Your_Dictionary)) You can look up the class File in godot docs)