Up to date

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

NavigationObstacle2D

Inherits: Node < Object

2D Obstacle used in navigation for collision avoidance.

Description

2D Obstacle used in navigation for collision avoidance. The obstacle needs navigation data to work correctly. NavigationObstacle2D is physics safe.

Obstacles don’t change the resulting path from the pathfinding, they only affect the navigation agent movement in a radius. Therefore, using obstacles for the static walls in your level won’t work because those walls don’t exist in the pathfinding. The navigation agent will be pushed in a semi-random direction away while moving inside that radius. Obstacles are intended as a last resort option for constantly moving objects that cannot be (re)baked to a navigation mesh efficiently.

Tutorials

Properties

bool

estimate_radius

true

float

radius

1.0

Methods

RID

get_navigation_map ( ) const

RID

get_rid ( ) const

void

set_navigation_map ( RID navigation_map )


Property Descriptions

bool estimate_radius = true

  • void set_estimate_radius ( bool value )

  • bool is_radius_estimated ( )

Enables radius estimation algorithm which uses parent’s collision shapes to determine the obstacle radius.


float radius = 1.0

  • void set_radius ( float value )

  • float get_radius ( )

The radius of the agent. Used only if estimate_radius is set to false.


Method Descriptions

RID get_navigation_map ( ) const

Returns the RID of the navigation map for this NavigationObstacle node. This function returns always the map set on the NavigationObstacle node and not the map of the abstract agent on the NavigationServer. If the agent map is changed directly with the NavigationServer API the NavigationObstacle node will not be aware of the map change. Use set_navigation_map to change the navigation map for the NavigationObstacle and also update the agent on the NavigationServer.


RID get_rid ( ) const

Returns the RID of this obstacle on the NavigationServer2D.


void set_navigation_map ( RID navigation_map )

Sets the RID of the navigation map this NavigationObstacle node should use and also updates the agent on the NavigationServer.