AStar

AStar class representation that uses vectors as edges.

A* (A star) is a computer algorithm that is widely used in pathfinding and graph traversal, the process of plotting an efficiently directed path between multiple points. It enjoys widespread use due to its performance and accuracy. Godot's A* implementation make use of vectors as points. You must add points manually with AStar.addPoint and create segments manually with AStar.connectPoints. So you can test if there is a path between two points with the AStar.arePointsConnected function, get the list of existing ids in the found path with AStar.getIdPath, or the points list with AStar.getPointPath.

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Functions

_computeCost
double _computeCost(long from_id, long to_id)

Called when computing the cost between two connected points.

_estimateCost
double _estimateCost(long from_id, long to_id)

Called when estimating the cost between a point and the path's ending point.

addPoint
void addPoint(long id, Vector3 position, double weight_scale)

Adds a new point at the given position with the given identifier. The algorithm prefers points with lower weight_scale to form a path. The id must be 0 or larger, and the weight_scale must be 1 or larger.

arePointsConnected
bool arePointsConnected(long id, long to_id)

Returns whether there is a connection/segment between the given points.

clear
void clear()

Clears all the points and segments.

connectPoints
void connectPoints(long id, long to_id, bool bidirectional)

Creates a segment between the given points.

disconnectPoints
void disconnectPoints(long id, long to_id)

Deletes the segment between the given points.

getAvailablePointId
long getAvailablePointId()

Returns the next available point id with no point associated to it.

getClosestPoint
long getClosestPoint(Vector3 to_position)

Returns the id of the closest point to to_position. Returns -1 if there are no points in the points pool.

getClosestPositionInSegment
Vector3 getClosestPositionInSegment(Vector3 to_position)

Returns the closest position to to_position that resides inside a segment between two connected points.

getIdPath
PoolIntArray getIdPath(long from_id, long to_id)

Returns an array with the ids of the points that form the path found by AStar between the given points. The array is ordered from the starting point to the ending point of the path.

getPointConnections
PoolIntArray getPointConnections(long id)

Returns an array with the ids of the points that form the connect with the given point.

getPointPath
PoolVector3Array getPointPath(long from_id, long to_id)

Returns an array with the points that are in the path found by AStar between the given points. The array is ordered from the starting point to the ending point of the path.

getPointPosition
Vector3 getPointPosition(long id)

Returns the position of the point associated with the given id.

getPointWeightScale
double getPointWeightScale(long id)

Returns the weight scale of the point associated with the given id.

getPoints
Array getPoints()

Returns an array of all points.

hasPoint
bool hasPoint(long id)

Returns whether a point associated with the given id exists.

opAssign
AStar opAssign(T n)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(AStar other)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(typeof(null) n)
Undocumented in source. Be warned that the author may not have intended to support it.
removePoint
void removePoint(long id)

Removes the point associated with the given id from the points pool.

setPointPosition
void setPointPosition(long id, Vector3 position)

Sets the position for the point with the given id.

setPointWeightScale
void setPointWeightScale(long id, double weight_scale)

Sets the weight_scale for the point with the given id.

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Static functions

_new
AStar _new()
Undocumented in source. Be warned that the author may not have intended to support it.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

_classBinding
struct _classBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
To as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
To as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
ToRef as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Meta