Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

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 )