0 votes

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...

asked Oct 8, 2017 in Engine by stillinthe90s (46 points)

1 Answer

0 votes

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 tojson().
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.storeline(tojson(Your_Dictionary)) You can look up the class File in godot docs)

answered Feb 9 by Sween123 (758 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.