NavigationServer2D
A server interface for low-level 2D navigation access.
A server interface for low-level 2D navigation access.
NavigationServer2D is the server that handles navigation maps, regions, and agents. It does not handle A* navigation from AStar2D or AStarGrid2D.
Maps are divided into regions, which are composed of navigation polygons. Together, they define the traversable areas in the 2D world.
Note: Most NavigationServer2D changes take effect after the next physics frame and not immediately. This includes all changes made to maps, regions, or agents by navigation-related nodes in the scene tree or made through scripts.
For two regions to be connected to each other, they must share a similar edge. An edge is considered connected to another if both of its two vertices are at a distance less than edge_connection_margin to the respective other edge's vertex.
You may assign navigation layers to regions with NavigationServer2D.RegionSetNavigationLayers, which then can be checked upon when requesting a path with NavigationServer2D.MapGetPath. This can be used to allow or deny certain areas for some objects.
To use the collision avoidance system, you may use agents. You can set an agent's target velocity, then the servers will emit a callback with a modified velocity.
Note: The collision avoidance system ignores regions. Using the modified velocity directly may move an agent outside of the traversable area. This is a limitation of the collision avoidance system, any more complex situation may require the use of the physics engine.
This server keeps tracks of any call and executes them during the sync phase. This means that you can request any change to the map, using any thread, without worrying.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties1
SingletonProperty
public static NavigationServer2DInstance Singleton { get; }Methods140
AgentCreateRid
public static Rid AgentCreate();Creates the agent.
RidAgentGetAvoidanceEnabledbool
public static bool AgentGetAvoidanceEnabled(Rid agent);Return true if the specified agent uses avoidance.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
boolAgentGetAvoidanceLayersuint
public static uint AgentGetAvoidanceLayers(Rid agent);Returns the avoidance_layers bitmask of the specified agent.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
uintAgentGetAvoidanceMaskuint
public static uint AgentGetAvoidanceMask(Rid agent);Returns the avoidance_mask bitmask of the specified agent.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
uintAgentGetAvoidancePriorityfloat
public static float AgentGetAvoidancePriority(Rid agent);Returns the avoidance_priority of the specified agent.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
floatAgentGetMapRid
public static Rid AgentGetMap(Rid agent);Reads the server agent map after processed assignments. Before synchronization it may differ from the Entity locally assigned map.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
agentRID of a live 2D server agent.
RidAssigned map RID, or a zero RID when unassigned.
AgentGetMaxNeighborsint
public static int AgentGetMaxNeighbors(Rid agent);Returns the maximum number of other agents the specified agent takes into account in the navigation.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
intAgentGetMaxSpeedfloat
public static float AgentGetMaxSpeed(Rid agent);Returns the maximum speed of the specified agent.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
floatAgentGetNeighborDistancefloat
public static float AgentGetNeighborDistance(Rid agent);Returns the maximum distance to other agents the specified agent takes into account in the navigation.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
floatAgentGetPausedbool
public static bool AgentGetPaused(Rid agent);Returns true if the specified agent is paused.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
boolAgentGetPositionVector2
public static Vector2 AgentGetPosition(Rid agent);Returns the position of the specified agent in world space.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
Vector2AgentGetRadiusfloat
public static float AgentGetRadius(Rid agent);Returns the radius of the specified agent.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
floatAgentGetTimeHorizonAgentsfloat
public static float AgentGetTimeHorizonAgents(Rid agent);Returns the minimal amount of time for which the specified agent's velocities that are computed by the simulation are safe with respect to other agents.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
floatAgentGetTimeHorizonObstaclesfloat
public static float AgentGetTimeHorizonObstacles(Rid agent);Returns the minimal amount of time for which the specified agent's velocities that are computed by the simulation are safe with respect to static avoidance obstacles.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
floatAgentGetVelocityVector2
public static Vector2 AgentGetVelocity(Rid agent);Returns the velocity of the specified agent.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
Vector2AgentHasAvoidanceCallbackbool
public static bool AgentHasAvoidanceCallback(Rid agent);Return true if the specified agent has an avoidance callback.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
boolAgentIsMapChangedbool
public static bool AgentIsMapChanged(Rid agent);Returns true if the map got changed the previous frame.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
boolAgentSetAvoidanceCallbackvoid
public static void AgentSetAvoidanceCallback(Rid agent, Callable callback);Sets the callback Callable that gets called after each avoidance processing step for the agent. The calculated safe_velocity will be dispatched with a signal to the object just before the physics calculations.
Note: Created callbacks are always processed independently of the EntityTree state as long as the agent is on a navigation map and not freed. To disable the dispatch of a callback from an agent use NavigationServer2D.AgentSetAvoidanceCallback again with an empty Callable.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
callback | Callable | — |
AgentSetAvoidanceEnabledvoid
public static void AgentSetAvoidanceEnabled(Rid agent, bool enabled);If enabled is true, the specified agent uses avoidance.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
enabled | bool | — |
AgentSetAvoidanceLayersvoid
public static void AgentSetAvoidanceLayers(Rid agent, uint layers);Set the agent's avoidance_layers bitmask.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
layers | uint | — |
AgentSetAvoidanceMaskvoid
public static void AgentSetAvoidanceMask(Rid agent, uint mask);Set the agent's avoidance_mask bitmask.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
mask | uint | — |
AgentSetAvoidancePriorityvoid
public static void AgentSetAvoidancePriority(Rid agent, float priority);Set the agent's avoidance_priority with a priority between 0.0 (lowest priority) to 1.0 (highest priority).
The specified agent does not adjust the velocity for other agents that would match the avoidance_mask but have a lower avoidance_priority. This in turn makes the other agents with lower priority adjust their velocities even more to avoid collision with this agent.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
priority | float | — |
AgentSetMapvoid
public static void AgentSetMap(Rid agent, Rid map);Queues a server agent map change. For a NavigationAgent2D Entity, normally use its SetNavigationMap to align both path queries and server membership.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
map | Rid | — |
agentRID of a live server agent, rather than a map, region or Entity ID.
map2D map RID. Separate maps do not form one shared avoidance simulation.
AgentSetMaxNeighborsvoid
public static void AgentSetMaxNeighbors(Rid agent, int count);Sets the maximum number of other agents the agent takes into account in the navigation. The larger this number, the longer the running time of the simulation. If the number is too low, the simulation will not be safe.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
count | int | — |
AgentSetMaxSpeedvoid
public static void AgentSetMaxSpeed(Rid agent, float maxSpeed);Sets the maximum speed of the agent. Must be positive.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
maxSpeed | float | — |
AgentSetNeighborDistancevoid
public static void AgentSetNeighborDistance(Rid agent, float distance);Sets the maximum distance to other agents this agent takes into account in the navigation. The larger this number, the longer the running time of the simulation. If the number is too low, the simulation will not be safe.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
distance | float | — |
AgentSetPausedvoid
public static void AgentSetPaused(Rid agent, bool paused);If paused is true the specified agent will not be processed. For example, it will not calculate avoidance velocities or receive avoidance callbacks.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
paused | bool | — |
AgentSetPositionvoid
public static void AgentSetPosition(Rid agent, Vector2 position);Sets the position of the agent in world space.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
position | Vector2 | — |
AgentSetRadiusvoid
public static void AgentSetRadius(Rid agent, float radius);Sets the radius of the agent.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
radius | float | — |
AgentSetTimeHorizonAgentsvoid
public static void AgentSetTimeHorizonAgents(Rid agent, float timeHorizon);The minimal amount of time for which the agent's velocities that are computed by the simulation are safe with respect to other agents. The larger this number, the sooner this agent will respond to the presence of other agents, but the less freedom this agent has in choosing its velocities. A too high value will slow down agent movement considerably. Must be positive.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
timeHorizon | float | — |
AgentSetTimeHorizonObstaclesvoid
public static void AgentSetTimeHorizonObstacles(Rid agent, float timeHorizon);The minimal amount of time for which the agent's velocities that are computed by the simulation are safe with respect to static avoidance obstacles. The larger this number, the sooner this agent will respond to the presence of static avoidance obstacles, but the less freedom this agent has in choosing its velocities. A too high value will slow down agent movement considerably. Must be positive.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
timeHorizon | float | — |
AgentSetVelocityvoid
public static void AgentSetVelocity(Rid agent, Vector2 velocity);Sets velocity as the new wanted velocity for the specified agent. The avoidance simulation will try to achieve this velocity if possible, but will adjust it to avoid colliding with other agents and obstacles. When an agent is teleported to a new position far away, use NavigationServer2D.AgentSetVelocityForced instead to reset the internal velocity state.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
velocity | Vector2 | — |
AgentSetVelocityForcedvoid
public static void AgentSetVelocityForced(Rid agent, Vector2 velocity);Replaces the internal velocity in the collision avoidance simulation with velocity for the specified agent. When an agent is teleported to a new position far away this function should be used in the same frame. If called frequently this function can get agents stuck.
| Name | Type | Default |
|---|---|---|
agent | Rid | — |
velocity | Vector2 | — |
BakeFromSourceGeometryDatavoid
public static void BakeFromSourceGeometryData(NavigationPolygon navigationPolygon, NavigationMeshSourceGeometryData2D sourceGeometryData, Callable callback = default);Synchronously bakes supplied source data into a navigation resource. Does not automatically parse the entire level or assign output to a region. Check polygon count, assign the resource and wait for map publication.
| Name | Type | Default |
|---|---|---|
navigationPolygon | NavigationPolygon | — |
sourceGeometryData | NavigationMeshSourceGeometryData2D | — |
callback | Callable | default |
navigationPolygonOutput resource with configured bake parameters, including radius and resolution. Its contents are modified by the call.
sourceGeometryDataPrepared source data of the corresponding dimension. Empty or unsuitable surfaces may produce no polygons.
BakeFromSourceGeometryDataAsyncvoid
public static void BakeFromSourceGeometryDataAsync(NavigationPolygon navigationPolygon, NavigationMeshSourceGeometryData2D sourceGeometryData, Callable callback = default);Bakes the provided navigation_polygon with the data from the provided source_geometry_data as an async task running on a background thread. After the process is finished the optional callback will be called.
| Name | Type | Default |
|---|---|---|
navigationPolygon | NavigationPolygon | — |
sourceGeometryData | NavigationMeshSourceGeometryData2D | — |
callback | Callable | default |
FreeRidvoid
public static void FreeRid(Rid rid);Destroys the given RID.
| Name | Type | Default |
|---|---|---|
rid | Rid | — |
GetDebugEnabledbool
public static bool GetDebugEnabled();Reads the server debug flag. An enabled flag does not prove geometry is visible: the corresponding Entity types provide standard visualization subject to additional settings.
boolCurrent flag value; this is not a visualization or path-correctness check.
GetMapsReckfell.Collections.Array<Rid>
GetProcessInfoint
public static int GetProcessInfo(NavigationServer2D.ProcessInfo processInfo);Reads a 2D server counter. Aggregates cover active maps after server processing, not all allocated RIDs. A disabled region remains in RegionCount while assigned to an active map. This does not measure search time.
| Name | Type | Default |
|---|---|---|
processInfo | NavigationServer2D.ProcessInfo | — |
processInfoCounter selection: ActiveMaps, RegionCount, PolygonCount, or another ProcessInfo value.
intInteger counter value. The latest map changes may still be awaiting processing.
IsBakingNavigationPolygonbool
public static bool IsBakingNavigationPolygon(NavigationPolygon navigationPolygon);Returns true when the provided navigation polygon is being baked on a background thread.
| Name | Type | Default |
|---|---|---|
navigationPolygon | NavigationPolygon | — |
boolLinkCreateRid
public static Rid LinkCreate();Creates a server navigation link and returns its RID. Configure its map, global endpoints and layers; it participates in pathfinding but does not move a character. Release the owned RID with FreeRid.
RidRID of the new link. Ownership requires a later FreeRid; a NavigationLink2D Entity manages its own RID separately.
LinkGetEnabledbool
public static bool LinkGetEnabled(Rid link);Returns true if the specified link is enabled.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
boolLinkGetEndPositionVector2
public static Vector2 LinkGetEndPosition(Rid link);Returns the ending position of this link.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
Vector2LinkGetEnterCostfloat
public static float LinkGetEnterCost(Rid link);Returns the enter cost of this link.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
floatLinkGetIterationIduint
public static uint LinkGetIterationId(Rid link);Returns the current iteration ID of the navigation link. Every time the navigation link changes and synchronizes, the iteration ID increases. An iteration ID of 0 means the navigation link has never synchronized.
Note: The iteration ID will wrap around to 1 after reaching its range limit.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
uintLinkGetMapRid
public static Rid LinkGetMap(Rid link);Returns the navigation map Rid the requested link is currently assigned to.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
RidLinkGetNavigationLayersuint
public static uint LinkGetNavigationLayers(Rid link);Returns the navigation layers for this link.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
uintLinkGetOwnerIdulong
public static ulong LinkGetOwnerId(Rid link);Returns the ObjectID of the object which manages this link.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
ulongLinkGetStartPositionVector2
public static Vector2 LinkGetStartPosition(Rid link);Returns the starting position of this link.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
Vector2LinkGetTravelCostfloat
public static float LinkGetTravelCost(Rid link);Returns the travel cost of this link.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
floatLinkIsBidirectionalbool
public static bool LinkIsBidirectional(Rid link);Returns whether this link can be travelled in both directions.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
boolLinkSetBidirectionalvoid
public static void LinkSetBidirectional(Rid link, bool bidirectional);Enables or disables reverse traversal. With false, traversal remains from the start endpoint to the end. The change requires an updated map version to be published.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
bidirectional | bool | — |
bidirectionaltrue for both directions, false for start → end only.
LinkSetEnabledvoid
public static void LinkSetEnabled(Rid link, bool enabled);Enables or disables link participation after synchronization. Does not stop a character animation or movement already in progress; the game controls those.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
enabled | bool | — |
enabledtrue to enable the link; false to omit its transition from new queries after the map updates.
LinkSetEndPositionvoid
public static void LinkSetEndPosition(Rid link, Vector2 position);Sets the server link global end endpoint. Moving it outside the connection radius breaks the checked route after synchronization. Does not relocate a gameplay body.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
position | Vector2 | — |
positionGlobal endpoint position in map coordinates.
LinkSetEnterCostvoid
public static void LinkSetEnterCost(Rid link, float enterCost);Sets the enter_cost for this link.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
enterCost | float | — |
LinkSetMapvoid
public static void LinkSetMap(Rid link, Rid map);Assigns a link to a navigation map. Both endpoints must connect to suitable polygons on that map. Queries see the change after the server publishes its update.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
map | Rid | — |
linkRID of a live link created by this server.
mapRID of the map containing the intended navigation regions; not a region RID.
LinkSetNavigationLayersvoid
public static void LinkSetNavigationLayers(Rid link, uint navigationLayers);Sets the link own navigation-layer mask. A query must admit both the link and its regions. With regions on layer 1 and a link on layer 2, query mask 3 works; mask 1 excludes the link.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
navigationLayers | uint | — |
navigationLayersUnsigned 32-bit mask; layer number N uses bit 1u << (N - 1), rather than the value N.
LinkSetOwnerIdvoid
public static void LinkSetOwnerId(Rid link, ulong ownerId);Sets an object owner ID for path metadata. The ID differs from the link RID. Assigning it neither creates an object nor transfers its lifetime management to the server.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
ownerId | ulong | — |
ownerIdFor example, GetInstanceId() of the live transition controller. Zero means no assigned object owner.
LinkSetStartPositionvoid
public static void LinkSetStartPosition(Rid link, Vector2 position);Sets the server link global start endpoint. One-way traversal runs from this endpoint to the end. Connection requires a suitable polygon within the map radius.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
position | Vector2 | — |
positionGlobal position in map coordinates. Unlike NavigationLink2D.StartPosition, this is not an Entity-local position.
LinkSetTravelCostvoid
public static void LinkSetTravelCost(Rid link, float travelCost);Sets the travel_cost for this link.
| Name | Type | Default |
|---|---|---|
link | Rid | — |
travelCost | float | — |
MapCreateRid
public static Rid MapCreate();Creates a separate navigation map without geometry. Its owner must enable processing, add regions, wait for publication and eventually release the map with FreeRid.
RidRID of the new map, rather than a region or Entity. Do not substitute an object from another dimension.
MapForceUpdatevoid · Deprecated
public static void MapForceUpdate(Rid map);This function immediately forces synchronization of the specified navigation map Rid. By default navigation maps are only synchronized at the end of each physics frame. This function can be used to immediately (re)calculate all the navigation meshes and region connections of the navigation map. This makes it possible to query a navigation path for a changed map immediately and in the same frame (multiple times if needed).
Due to technical restrictions the current NavigationServer command queue will be flushed. This means all already queued update commands for this physics frame will be executed, even those intended for other maps, regions, and agents not part of the specified map. The expensive computation of the navigation meshes and region connections of a map will only be done for the specified map. Other maps will receive the normal synchronization at the end of the physics frame. Should the specified map receive changes after the forced update it will update again as well when the other maps receive their update.
Avoidance processing and dispatch of the safe_velocity signals is unaffected by this function and continues to happen for all maps and agents at the end of the physics frame.
Note: With great power comes great responsibility. This function should only be used by users that really know what they are doing and have a good reason for it. Forcing an immediate update of a navigation map requires locking the NavigationServer and flushing the entire NavigationServer command queue. Not only can this severely impact the performance of a game but it can also introduce bugs if used inappropriately without much foresight.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
MapGetAgentsReckfell.Collections.Array<Rid>
public static Reckfell.Collections.Array<Rid> MapGetAgents(Rid map);Returns all navigation agent Rids that are currently assigned to the requested navigation map.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
Reckfell.Collections.Array<Rid>MapGetCellSizefloat
public static float MapGetCellSize(Rid map);Returns the map cell size used to rasterize the navigation mesh vertices.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
floatMapGetClosestPointVector2
public static Vector2 MapGetClosestPoint(Rid map, Vector2 toPoint);Returns the navigation mesh surface point closest to the provided to_point on the navigation map.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
toPoint | Vector2 | — |
Vector2MapGetClosestPointOwnerRid
public static Rid MapGetClosestPointOwner(Rid map, Vector2 toPoint);Returns the owner region RID for the navigation mesh surface point closest to the provided to_point on the navigation map.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
toPoint | Vector2 | — |
RidMapGetEdgeConnectionMarginfloat
public static float MapGetEdgeConnectionMargin(Rid map);Returns the edge connection margin of the map. The edge connection margin is a distance used to connect two regions.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
floatMapGetIterationIduint
public static uint MapGetIterationId(Rid map);Returns the current iteration id of the navigation map. Every time the navigation map changes and synchronizes the iteration id increases. An iteration id of 0 means the navigation map has never synchronized. Note: The iteration id will wrap back to 1 after reaching its range limit.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
uintMapGetLinkConnectionRadiusfloat
public static float MapGetLinkConnectionRadius(Rid map);Returns the link connection radius of the map. This distance is the maximum range any link will search for navigation mesh polygons to connect to.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
floatMapGetLinksReckfell.Collections.Array<Rid>
public static Reckfell.Collections.Array<Rid> MapGetLinks(Rid map);Returns all navigation link Rids that are currently assigned to the requested navigation map.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
Reckfell.Collections.Array<Rid>MapGetMergeRasterizerCellScalefloat
public static float MapGetMergeRasterizerCellScale(Rid map);Returns the map's internal merge rasterizer cell scale.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
floatMapGetObstaclesReckfell.Collections.Array<Rid>
public static Reckfell.Collections.Array<Rid> MapGetObstacles(Rid map);Returns all navigation obstacle Rids that are currently assigned to the requested navigation map.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
Reckfell.Collections.Array<Rid>MapGetPathVector2[]
public static Vector2[] MapGetPath(Rid map, Vector2 origin, Vector2 destination, bool optimize, uint navigationLayers = 1);Queries path points on a published map. A nonempty result may be partial or have projected start/target positions; check both endpoints. The array neither moves a character nor updates itself after map changes.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
origin | Vector2 | — |
destination | Vector2 | — |
optimize | bool | — |
navigationLayers | uint | 1 |
mapRID of a live navigation map in this dimension with published geometry.
originStart in map-global coordinates; the first result point may be projected onto an accessible surface.
destinationTarget in map-global coordinates; the last result point may differ when it is unreachable.
optimizetrue uses Corridorfunnel within the found corridor; false uses Edgecentered. Does not disable A* or guarantee less computation.
navigationLayersMask of permitted region and link layers; defaults to 1. Layer N is bit 1u << (N - 1).
Vector2[]Vector2[] route points; empty when no suitable path is returned. Existing points do not guarantee reaching the requested target or physically safe movement.
MapGetRandomPointVector2
public static Vector2 MapGetRandomPoint(Rid map, uint navigationLayers, bool uniformly);Returns a random position picked from all map region polygons with matching navigation_layers.
If uniformly is true, all map regions, polygons, and faces are weighted by their surface area (slower).
If uniformly is false, just a random region and a random polygon are picked (faster).
| Name | Type | Default |
|---|---|---|
map | Rid | — |
navigationLayers | uint | — |
uniformly | bool | — |
Vector2MapGetRegionsReckfell.Collections.Array<Rid>
public static Reckfell.Collections.Array<Rid> MapGetRegions(Rid map);Returns registered map regions. Moving a region updates old and new membership when the command is processed. Region membership does not establish polygon readiness.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
mapRID of the map whose region membership is needed.
Reckfell.Collections.Array<Rid>Array of region RIDs rather than Entity IDs. May be empty.
MapGetUseAsyncIterationsbool
public static bool MapGetUseAsyncIterations(Rid map);Returns true if the map synchronization uses an async process that runs on a background thread.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
boolMapGetUseEdgeConnectionsbool
public static bool MapGetUseEdgeConnections(Rid map);Returns whether the navigation map allows navigation regions to use edge connections to connect with other navigation regions within proximity of the navigation map edge connection margin.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
boolMapIsActivebool
public static bool MapIsActive(Rid map);Checks map participation in server processing, rather than geometry presence or query permission. MapSetActive changes pass through a queue.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
mapRID of a live 2D map.
booltrue when the map is included in processing; false does not mean an already published path cannot be queried.
MapSetActivevoid
public static void MapSetActive(Rid map, bool active);Enables or disables the map participation in server processing. False does not prohibit direct queries against already published navigation, as verified in the installed build. Pause character behavior through game logic.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
active | bool | — |
mapMap RID belonging to the corresponding NavigationServer.
activetrue includes the map in processing; false removes it. This is not a path-query permission flag.
MapSetCellSizevoid
public static void MapSetCellSize(Rid map, float cellSize);Sets the map cell size used to rasterize the navigation mesh vertices. Must match with the cell size of the used navigation meshes.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
cellSize | float | — |
MapSetEdgeConnectionMarginvoid
public static void MapSetEdgeConnectionMargin(Rid map, float margin);Configures the distance for additional near-edge connections. Does not control every map-grid merge or guarantee arbitrary edge connections. Wait for an update and check a new path after changing it.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
margin | float | — |
mapRID of the map whose connections are being configured.
marginMargin in map units. Excessive values may connect unintended gaps; this does not authorize a physical character to jump a gap.
MapSetLinkConnectionRadiusvoid
public static void MapSetLinkConnectionRadius(Rid map, float radius);Sets the polygon search radius around each navigation-link endpoint on the map. This is not the maximum distance between endpoints. Without a suitable polygon near either endpoint, there is no complete transition.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
radius | float | — |
radiusRadius in map coordinate units; account for it when placing global link endpoints.
MapSetMergeRasterizerCellScalevoid
public static void MapSetMergeRasterizerCellScale(Rid map, float scale);Set the map's internal merge rasterizer cell scale used to control merging sensitivity.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
scale | float | — |
MapSetUseAsyncIterationsvoid
public static void MapSetUseAsyncIterations(Rid map, bool enabled);If enabled is true the map synchronization uses an async process that runs on a background thread.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
enabled | bool | — |
MapSetUseEdgeConnectionsvoid
public static void MapSetUseEdgeConnections(Rid map, bool enabled);Enables or disables additional map edge connections. Disabling does not guarantee separation of edges merged through the grid, as checked with a subcell gap.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
enabled | bool | — |
enabledtrue permits additional connections; false disables this mechanism after the map updates.
ObstacleCreateRid
public static Rid ObstacleCreate();Creates a new navigation obstacle.
RidObstacleGetAvoidanceEnabledbool
public static bool ObstacleGetAvoidanceEnabled(Rid obstacle);Returns true if the provided obstacle has avoidance enabled.
| Name | Type | Default |
|---|---|---|
obstacle | Rid | — |
boolObstacleGetAvoidanceLayersuint
public static uint ObstacleGetAvoidanceLayers(Rid obstacle);Returns the avoidance_layers bitmask of the specified obstacle.
| Name | Type | Default |
|---|---|---|
obstacle | Rid | — |
uintObstacleGetMapRid
public static Rid ObstacleGetMap(Rid obstacle);Returns the navigation map Rid the requested obstacle is currently assigned to.
| Name | Type | Default |
|---|---|---|
obstacle | Rid | — |
RidObstacleGetPausedbool
public static bool ObstacleGetPaused(Rid obstacle);Returns true if the specified obstacle is paused.
| Name | Type | Default |
|---|---|---|
obstacle | Rid | — |
boolObstacleGetPositionVector2
public static Vector2 ObstacleGetPosition(Rid obstacle);Returns the position of the specified obstacle in world space.
| Name | Type | Default |
|---|---|---|
obstacle | Rid | — |
Vector2ObstacleGetRadiusfloat
public static float ObstacleGetRadius(Rid obstacle);Returns the radius of the specified dynamic obstacle.
| Name | Type | Default |
|---|---|---|
obstacle | Rid | — |
floatObstacleGetVelocityVector2
public static Vector2 ObstacleGetVelocity(Rid obstacle);Returns the velocity of the specified dynamic obstacle.
| Name | Type | Default |
|---|---|---|
obstacle | Rid | — |
Vector2ObstacleGetVerticesVector2[]
public static Vector2[] ObstacleGetVertices(Rid obstacle);Returns the outline vertices for the specified obstacle.
| Name | Type | Default |
|---|---|---|
obstacle | Rid | — |
Vector2[]ObstacleSetAvoidanceEnabledvoid
public static void ObstacleSetAvoidanceEnabled(Rid obstacle, bool enabled);If enabled is true, the provided obstacle affects avoidance using agents.
| Name | Type | Default |
|---|---|---|
obstacle | Rid | — |
enabled | bool | — |
ObstacleSetAvoidanceLayersvoid
public static void ObstacleSetAvoidanceLayers(Rid obstacle, uint layers);Sets the given obstacle's avoidance layers to layers.
| Name | Type | Default |
|---|---|---|
obstacle | Rid | — |
layers | uint | — |
ObstacleSetMapvoid
public static void ObstacleSetMap(Rid obstacle, Rid map);Sets the navigation map Rid for the obstacle.
| Name | Type | Default |
|---|---|---|
obstacle | Rid | — |
map | Rid | — |
ObstacleSetPausedvoid
public static void ObstacleSetPaused(Rid obstacle, bool paused);If paused is true the specified obstacle will not be processed. For example, it will no longer affect avoidance velocities.
| Name | Type | Default |
|---|---|---|
obstacle | Rid | — |
paused | bool | — |
ObstacleSetPositionvoid
public static void ObstacleSetPosition(Rid obstacle, Vector2 position);Sets the position of the obstacle in world space.
| Name | Type | Default |
|---|---|---|
obstacle | Rid | — |
position | Vector2 | — |
ObstacleSetRadiusvoid
public static void ObstacleSetRadius(Rid obstacle, float radius);Sets the radius of the dynamic obstacle.
| Name | Type | Default |
|---|---|---|
obstacle | Rid | — |
radius | float | — |
ObstacleSetVelocityvoid
public static void ObstacleSetVelocity(Rid obstacle, Vector2 velocity);Sets velocity of the dynamic obstacle. Allows other agents to better predict the movement of the dynamic obstacle. Only works in combination with the radius of the obstacle.
| Name | Type | Default |
|---|---|---|
obstacle | Rid | — |
velocity | Vector2 | — |
ObstacleSetVertices2 overloads
public static void ObstacleSetVertices(Rid obstacle, Vector2[] vertices);Sets the outline vertices for the obstacle. If the vertices are winded in clockwise order agents will be pushed in by the obstacle, else they will be pushed out.
| Name | Type | Default |
|---|---|---|
obstacle | Rid | — |
vertices | Vector2[] | — |
public static void ObstacleSetVertices(Rid obstacle, ReadOnlySpan<Vector2> vertices);Sets the outline vertices for the obstacle. If the vertices are winded in clockwise order agents will be pushed in by the obstacle, else they will be pushed out.
| Name | Type | Default |
|---|---|---|
obstacle | Rid | — |
vertices | ReadOnlySpan<Vector2> | — |
ParseSourceGeometryDatavoid
public static void ParseSourceGeometryData(NavigationPolygon navigationPolygon, NavigationMeshSourceGeometryData2D sourceGeometryData, Entity rootEntity, Callable callback = default);Parses the EntityTree for source geometry according to the properties of navigation_polygon. Updates the provided source_geometry_data resource with the resulting data. The resource can then be used to bake a navigation mesh with NavigationServer2D.BakeFromSourceGeometryData. After the process is finished the optional callback will be called.
Note: This function needs to run on the main thread or with a deferred call as the EntityTree is not thread-safe.
Performance: While convenient, reading data arrays from Mesh resources can affect the frame rate negatively. The data needs to be received from the GPU, stalling the RenderingServer in the process. For performance prefer the use of e.g. collision shapes or creating the data arrays entirely in code.
| Name | Type | Default |
|---|---|---|
navigationPolygon | NavigationPolygon | — |
sourceGeometryData | NavigationMeshSourceGeometryData2D | — |
rootEntity | Entity | — |
callback | Callable | default |
QueryPath2 overloads
public static void QueryPath(NavigationPathQueryParameters2D parameters, NavigationPathQueryResult2D result);Executes a query using the parameters and replaces result data. The result does not track a moving target automatically: call again for a new request. The map must exist and be synchronized; a nonempty path can be partial.
| Name | Type | Default |
|---|---|---|
parameters | NavigationPathQueryParameters2D | — |
result | NavigationPathQueryResult2D | — |
parametersParameters containing the live map, global coordinates, mask and filters. May be reused; explicitly clear obsolete filters and limits.
resultObject receiving this query points, length and selected metadata. Use separate results for independent concurrent requests.
public static void QueryPath(NavigationPathQueryParameters2D parameters, NavigationPathQueryResult2D result, Callable callback = default);Queries a path in a given navigation map. Start and target position and other parameters are defined through NavigationPathQueryParameters2D. Updates the provided NavigationPathQueryResult2D result object with the path among other results requested by the query. After the process is finished the optional callback will be called.
| Name | Type | Default |
|---|---|---|
parameters | NavigationPathQueryParameters2D | — |
result | NavigationPathQueryResult2D | — |
callback | Callable | default |
RegionCreateRid
public static Rid RegionCreate();Creates a new region.
RidRegionGetBoundsRect2
public static Rect2 RegionGetBounds(Rid region);Reads processed region-navigation bounds in map space. Wait for an update after transform changes. These are navigation bounds rather than visual-mesh or physics-shape bounds.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
Rect2Rectangle bounding region navigation vertices after the applied transform.
RegionGetClosestPointVector2
public static Vector2 RegionGetClosestPoint(Rid region, Vector2 toPoint);Returns the navigation mesh surface point closest to the provided to_point on the navigation region.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
toPoint | Vector2 | — |
Vector2RegionGetConnectionPathwayEndVector2
public static Vector2 RegionGetConnectionPathwayEnd(Rid region, int connection);Returns the ending point of a connection door. connection is an index between 0 and the return value of NavigationServer2D.RegionGetConnectionsCount.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
connection | int | — |
Vector2RegionGetConnectionPathwayStartVector2
public static Vector2 RegionGetConnectionPathwayStart(Rid region, int connection);Returns the starting point of a connection door. connection is an index between 0 and the return value of NavigationServer2D.RegionGetConnectionsCount.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
connection | int | — |
Vector2RegionGetConnectionsCountint
public static int RegionGetConnectionsCount(Rid region);Returns the region additional connections prepared by the map. Useful for margin-connection diagnostics rather than a universal reachability test: grid merging and query filters require separate checks.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
intNumber of prepared additional connections; verify a route with a fresh path query.
RegionGetEnabledbool
public static bool RegionGetEnabled(Rid region);Returns true if the specified region is enabled.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
boolRegionGetEnterCostfloat
public static float RegionGetEnterCost(Rid region);Returns the enter cost of this region.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
floatRegionGetIterationIduint
public static uint RegionGetIterationId(Rid region);Returns the current iteration ID of the navigation region. Every time the navigation region changes and synchronizes, the iteration ID increases. An iteration ID of 0 means the navigation region has never synchronized.
Note: The iteration ID will wrap around to 1 after reaching its range limit.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
uintRegionGetMapRid
public static Rid RegionGetMap(Rid region);Reads current server-side region membership. Immediately after RegionSetMap it can still return the previous value before queue processing.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
regionRID of a live 2D region.
RidAssigned map RID, or a zero RID for a detached region.
RegionGetNavigationLayersuint
public static uint RegionGetNavigationLayers(Rid region);Returns the region's navigation layers.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
uintRegionGetOwnerIdulong
public static ulong RegionGetOwnerId(Rid region);Returns the ObjectID of the object which manages this region.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
ulongRegionGetRandomPointVector2
public static Vector2 RegionGetRandomPoint(Rid region, uint navigationLayers, bool uniformly);Returns a random position picked from all region polygons with matching navigation_layers.
If uniformly is true, all region polygons and faces are weighted by their surface area (slower).
If uniformly is false, just a random polygon and face is picked (faster).
| Name | Type | Default |
|---|---|---|
region | Rid | — |
navigationLayers | uint | — |
uniformly | bool | — |
Vector2RegionGetTransformTransform2D
public static Transform2D RegionGetTransform(Rid region);Returns the global transformation of this region.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
Transform2DRegionGetTravelCostfloat
public static float RegionGetTravelCost(Rid region);Returns the travel cost of this region.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
floatRegionGetUseAsyncIterationsbool
public static bool RegionGetUseAsyncIterations(Rid region);Returns true if the region uses an async synchronization process that runs on a background thread.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
boolRegionGetUseEdgeConnectionsbool
public static bool RegionGetUseEdgeConnections(Rid region);Returns whether the navigation region is set to use edge connections to connect with other navigation regions within proximity of the navigation map edge connection margin.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
boolRegionOwnsPointbool
public static bool RegionOwnsPoint(Rid region, Vector2 point);Returns true if the provided point in world space is currently owned by the provided navigation region. Owned in this context means that one of the region's navigation mesh polygon faces has a possible position at the closest distance to this point compared to all other navigation meshes from other navigation regions that are also registered on the navigation map of the provided region.
If multiple navigation meshes have positions at equal distance the navigation region whose polygons are processed first wins the ownership. Polygons are processed in the same order that navigation regions were registered on the NavigationServer.
Note: If navigation meshes from different navigation regions overlap (which should be avoided in general) the result might not be what is expected.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
point | Vector2 | — |
boolRegionSetEnabledvoid
public static void RegionSetEnabled(Rid region, bool enabled);Includes or excludes the region in new queries after the map updates. Previously returned path arrays are not rewritten: the game must query again and handle unreachable results.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
enabled | bool | — |
enabledtrue enables the region; false excludes it from new searches after synchronization.
RegionSetEnterCostvoid
public static void RegionSetEnterCost(Rid region, float enterCost);Sets the enter_cost for this region.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
enterCost | float | — |
RegionSetMapvoid
public static void RegionSetMap(Rid region, Rid map);Queues region map assignment. A region belongs to one map; migration removes previous membership. A zero map RID detaches the region without freeing it.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
map | Rid | — |
regionRID of the live region to assign or detach.
map2D map RID, or default to detach. Does not transfer ownership of the region RID.
RegionSetNavigationLayersvoid
public static void RegionSetNavigationLayers(Rid region, uint navigationLayers);Set the region's navigation layers. This allows selecting regions from a path request (when using NavigationServer2D.MapGetPath).
| Name | Type | Default |
|---|---|---|
region | Rid | — |
navigationLayers | uint | — |
RegionSetNavigationPolygonvoid
public static void RegionSetNavigationPolygon(Rid region, NavigationPolygon navigationPolygon);Sets the navigation_polygon for the region.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
navigationPolygon | NavigationPolygon | — |
RegionSetOwnerIdvoid
public static void RegionSetOwnerId(Rid region, ulong ownerId);Set the ObjectID of the object which manages this region.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
ownerId | ulong | — |
RegionSetTransformvoid
public static void RegionSetTransform(Rid region, Transform2D transform);Sets placement of region navigation geometry on the map. Vertex translation and scaling were verified in the installed 2D server. Does not rebake character clearance or automatically carry a physics body.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
transform | Transform2D | — |
transformTransform from local navigation vertices to map space; Identity restores original placement.
RegionSetTravelCostvoid
public static void RegionSetTravelCost(Rid region, float travelCost);Sets the travel_cost for this region.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
travelCost | float | — |
RegionSetUseAsyncIterationsvoid
public static void RegionSetUseAsyncIterations(Rid region, bool enabled);If enabled is true the region uses an async synchronization process that runs on a background thread.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
enabled | bool | — |
RegionSetUseEdgeConnectionsvoid
public static void RegionSetUseEdgeConnections(Rid region, bool enabled);Controls region participation in additional edge connections. Disabling broke the checked margin connection between separate rectangles. Grid merging remains a distinct mechanism.
| Name | Type | Default |
|---|---|---|
region | Rid | — |
enabled | bool | — |
enabledWhether additional connections are allowed for the region; navigation must update before the change is visible.
SetActivevoid
public static void SetActive(bool active);Control activation of this server.
| Name | Type | Default |
|---|---|---|
active | bool | — |
SetDebugEnabledvoid
public static void SetDebugEnabled(bool enabled);Changes the flag in a DEBUG_ENABLED build and defers change notification. Without that option the setter body does not execute. Does not create visualization for arbitrary server RIDs.
| Name | Type | Default |
|---|---|---|
enabled | bool | — |
enabledtrue to enable, false to disable. Save and restore the original value for temporary diagnostics.
SimplifyPath2 overloads
public static Vector2[] SimplifyPath(Vector2[] path, float epsilon);Returns a simplified version of path with less critical path points removed. The simplification amount is in world units and controlled by epsilon. The simplification uses a variant of Ramer-Douglas-Peucker algorithm for curve point decimation.
Path simplification can be helpful to mitigate various path following issues that can arise with certain agent types and script behaviors. E.g. "steering" agents or avoidance in "open fields".
| Name | Type | Default |
|---|---|---|
path | Vector2[] | — |
epsilon | float | — |
Vector2[]public static Vector2[] SimplifyPath(ReadOnlySpan<Vector2> path, float epsilon);Returns a simplified version of path with less critical path points removed. The simplification amount is in world units and controlled by epsilon. The simplification uses a variant of Ramer-Douglas-Peucker algorithm for curve point decimation.
Path simplification can be helpful to mitigate various path following issues that can arise with certain agent types and script behaviors. E.g. "steering" agents or avoidance in "open fields".
| Name | Type | Default |
|---|---|---|
path | ReadOnlySpan<Vector2> | — |
epsilon | float | — |
Vector2[]SourceGeometryParserCreateRid
public static Rid SourceGeometryParserCreate();Creates a new source geometry parser. If a Callable is set for the parser with NavigationServer2D.SourceGeometryParserSetCallback the callback will be called for every single node that gets parsed whenever NavigationServer2D.ParseSourceGeometryData is used.
RidSourceGeometryParserSetCallbackvoid
public static void SourceGeometryParserSetCallback(Rid parser, Callable callback);Sets the callback Callable for the specific source geometry parser. The Callable will receive a call with the following parameters:
navigation_mesh- TheNavigationPolygonreference used to define the parse settings. Do NOT edit or add directly to the navigation mesh.source_geometry_data- TheNavigationMeshSourceGeometryData2Dreference. Add custom source geometry for navigation mesh baking to this object.node- TheEntitythat is parsed.
| Name | Type | Default |
|---|---|---|
parser | Rid | — |
callback | Callable | — |
Signals and events3
AvoidanceDebugChangedEvent
public static event Action AvoidanceDebugChanged;Emitted when avoidance debug settings are changed. Only available in debug builds.
MapChangedEvent
public static event NavigationServer2D.MapChangedEventHandler MapChanged;Emitted when a navigation map is updated, when a region moves or is modified.
| Name | Type | Default |
|---|---|---|
map | Rid | — |
NavigationDebugChangedEvent
public static event Action NavigationDebugChanged;Emitted when navigation debug settings are changed. Only available in debug builds.
NavigationServer2D.ProcessInfo
| Value | Description |
|---|---|
ActiveMaps = 0 | Constant to get the number of active navigation maps. |
AgentCount = 2 | Constant to get the number of active navigation agents processing avoidance. |
EdgeConnectionCount = 7 | Constant to get the number of navigation mesh polygon edges that are considered connected by edge proximity. |
EdgeCount = 5 | Constant to get the number of navigation mesh polygon edges. |
EdgeFreeCount = 8 | Constant to get the number of navigation mesh polygon edges that could not be merged but may be still connected by edge proximity or with links. |
EdgeMergeCount = 6 | Constant to get the number of navigation mesh polygon edges that were merged due to edge key overlap. |
LinkCount = 3 | Constant to get the number of active navigation links. |
ObstacleCount = 9 | Constant to get the number of active navigation obstacles. |
PolygonCount = 4 | Constant to get the number of navigation mesh polygons. |
RegionCount = 1 | Constant to get the number of active navigation regions. |