Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | koder | |
Old Version | Published before Godot 3 was released. |
I can’t find documentation on how AStar is supposed to be used. API reference does give some hints, but there is much guesswork. Is there a tutorial somewhere?
I assume the workflow is to initialize an AStar, supply it with points with (add_point
), add connections (connect_points
) between the points and then query paths with get_id_path
or get_point_path
. My specific questions are:
- Can I use any integer point id, or should I use
get_available_pint_id
to generate it? - Basic A* algorithm works on nodes and has nothing to do with 3d space. Methods accept Vector3 pos; is this a convenience method that can be ignored, or do I need actual 3d representation of node map?
- I first assumed that I should extend AStar and implement my own
_compute_cost
and_estimate_cost
, but with return signature of(int,int)=>void
I am not sure what these should do. Shouldn’t these return a float? If so: - What’s the difference between these two?
- How do they interact with weight from
add_point
? - Will they always be called on connected points?
- What should be valid return range?
- Which of functions are CPU expensive? Are there any caching/pre-computing going on? For example:
- If I ask for a path (1,7) and I get [1,2,3,4,5,6,7], does querying later for path (2,7) re-use computation, or is it up to me to cache it?
- Is creating new AStar cheap enough to be re-created on every AI decision?
Apologies if these topics were covered somewhere and TIA for any answer.