Table of Contents

Class PolygonPathFinder

Inheritance
PolygonPathFinder

Methods

find_path(Vector2, Vector2)

PackedVector2Array find_path(Vector2 from, Vector2 to)

Parameters

from Vector2
to Vector2

get_bounds

Qualifiers: const

Rect2 get_bounds

get_closest_point(Vector2)

Qualifiers: const

Vector2 get_closest_point(Vector2 point)

Parameters

point Vector2

get_intersections(Vector2, Vector2)

Qualifiers: const

PackedVector2Array get_intersections(Vector2 from, Vector2 to)

Parameters

from Vector2
to Vector2

get_point_penalty(int)

Qualifiers: const

float get_point_penalty(int idx)

Parameters

idx int

is_point_inside(Vector2)

Qualifiers: const

Returns true if point falls inside the polygon area.

var polygon_path_finder = PolygonPathFinder.new()
var points = [Vector2(0.0, 0.0), Vector2(1.0, 0.0), Vector2(0.0, 1.0)]
var connections = [0, 1, 1, 2, 2, 0]
polygon_path_finder.setup(points, connections)
print(polygon_path_finder.is_point_inside(Vector2(0.2, 0.2))) # Prints true
print(polygon_path_finder.is_point_inside(Vector2(1.0, 1.0))) # Prints false

bool is_point_inside(Vector2 point)

Parameters

point Vector2

set_point_penalty(int, float)

void set_point_penalty(int idx, float penalty)

Parameters

idx int
penalty float

setup(PackedVector2Array, PackedInt32Array)

Sets up PolygonPathFinder with an array of points that define the vertices of the polygon, and an array of indices that determine the edges of the polygon.

The length of connections must be even, returns an error if odd.

var polygon_path_finder = PolygonPathFinder.new()
var points = [Vector2(0.0, 0.0), Vector2(1.0, 0.0), Vector2(0.0, 1.0)]
var connections = [0, 1, 1, 2, 2, 0]
polygon_path_finder.setup(points, connections)

void setup(PackedVector2Array points, PackedInt32Array connections)

Parameters

points PackedVector2Array
connections PackedInt32Array