AStar2D

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 find the shortest path between two vertices on a connected graph in 2D space.

See AStar3D for a more thorough explanation on how to use this class. AStar2D is a wrapper for AStar3D that enforces 2D coordinates.

Methods

float

_compute_cost ( int from_id, int to_id ) virtual const

float

_estimate_cost ( int from_id, int to_id ) virtual const

void

add_point ( int id, Vector2 position, float weight_scale=1.0 )

bool

are_points_connected ( int id, int to_id, bool bidirectional=true ) const

void

clear ( )

void

connect_points ( int id, int to_id, bool bidirectional=true )

void

disconnect_points ( int id, int to_id, bool bidirectional=true )

int

get_available_point_id ( ) const

int

get_closest_point ( Vector2 to_position, bool include_disabled=false ) const

Vector2

get_closest_position_in_segment ( Vector2 to_position ) const

PackedInt64Array

get_id_path ( int from_id, int to_id )

int

get_point_capacity ( ) const

PackedInt64Array

get_point_connections ( int id )

int

get_point_count ( ) const

PackedInt64Array

get_point_ids ( )

PackedVector2Array

get_point_path ( int from_id, int to_id )

Vector2

get_point_position ( int id ) const

float

get_point_weight_scale ( int id ) const

bool

has_point ( int id ) const

bool

is_point_disabled ( int id ) const

void

remove_point ( int id )

void

reserve_space ( int num_nodes )

void

set_point_disabled ( int id, bool disabled=true )

void

set_point_position ( int id, Vector2 position )

void

set_point_weight_scale ( int id, float weight_scale )


Method Descriptions

float _compute_cost ( int from_id, int to_id ) virtual const

Called when computing the cost between two connected points.

Note that this function is hidden in the default AStar2D class.


float _estimate_cost ( int from_id, int to_id ) virtual const

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

Note that this function