Navigation2D

Inherits: Node2D < CanvasItem < Node < Object

2D navigation and pathfinding node.

Description

Deprecated. Navigation2D node and get_simple_path are deprecated and will be removed in a future version. Use Navigation2DServer.map_get_path instead.

Navigation2D provides navigation and pathfinding within a 2D area, specified as a collection of NavigationPolygon resources. By default, these are automatically collected from child NavigationPolygonInstance nodes.

Tutorials

Properties

float

cell_size

1.0

float

edge_connection_margin

1.0

int

navigation_layers

1

Methods

Vector2

get_closest_point ( Vector2 to_point ) const

RID

get_closest_point_owner ( Vector2 to_point ) const

RID

get_rid ( ) const

PoolVector2Array

get_simple_path ( Vector2 start, Vector2 end, bool optimize=true ) const

Property Descriptions

Default

1.0

Setter

set_cell_size(value)

Getter

get_cell_size()

The XY plane cell size to use for fields.


  • float edge_connection_margin

Default

1.0

Setter

set_edge_connection_margin(value)

Getter

get_edge_connection_margin()

This value is used to detect the near edges to connect compatible regions.


  • int navigation_layers

Default

1

Setter

set_navigation_layers(value)

Getter

get_navigation_layers()

A bitfield determining all navigation map layers the navigation can use on a get_simple_path path query.

Method Descriptions

Returns the navigation point closest to the point given. Points are in local coordinate space.


  • RID get_closest_point_owner ( Vector2 to_point ) const

Returns the owner of the NavigationPolygon which contains the navigation point closest to the point given. This is usually a NavigationPolygonInstance.


  • RID get_rid ( ) const

Returns the object’s RID.


Deprecated. Navigation2D node and get_simple_path are deprecated and will be removed in a future version. Use Navigation2DServer.map_get_path instead.

Returns the path between two given points. Points are in local coordinate space. If optimize is true (the default), the path is smoothed by merging path segments where possible.