I have this simple AStar2D graph with 3 points. They are connected as shown.
Assumptions:
- The character is always asked to move towards a point in the AStar2D graph.
- It takes time to move between the points and so there are frames where the character is located between two points.
- The character can receive a new command to move to a new point at any time.
- Thus, the character may be between points when a new move command is received.
For instance, the player may be at point A or B in the drawing.
I'm trying to think of the best way to implement this logic with the existing AStar2D methods (https://docs.godotengine.org/en/stable/classes/class_astar2d.html#class-astar2d-method-get-point-path). Any suggestions?
If I could use any possible logic, then I would do the following:
- When it's time to move, identify the two closest AStar points to the character.
- Connect the character to the two nearest AStar points.
- Use AStar to find a path to the desired point.
- Store the path and continue to move along that path each frame.
I can't do this because there is no easy way to identify the two nearest points to the character. (I could implement this myself in GDScript though.)
I'm wondering if I'm just missing an obvious solution, or if the AStar2D class is half-baked and missing some useful methods?
Inherits: RefCounted< Object An implementation of A* for finding the shortest path between two vertices on a connected graph in 2D space. Description: An implementation of the A* algorithm, used to...