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

in Engine by (46 points)

1 Answer

0 votes

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)

by (813 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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.