reckfellENGINE

NavigationAgent2D

A 2D agent used to pathfind to a position while avoiding obstacles.

On this page
class NavigationAgent2DReckfellSharpInherits Entity

A 2D agent used to pathfind to a position while avoiding obstacles.

A 2D agent used to pathfind to a position while avoiding static and dynamic obstacles. The calculation can be used by the parent node to dynamically move it along the path. Requires navigation data to work correctly. Dynamic obstacles are avoided using RVO collision avoidance. Avoidance is computed before physics, so the pathfinding information can be used safely in the physics step. Note: After setting the NavigationAgent2D.TargetPosition property, the NavigationAgent2D.GetNextPathPosition method must be used once every physics frame to update the internal path logic of the navigation agent. The vector position it returns should be used as the next movement position for the agent's parent node. Note: Several methods of this class, such as NavigationAgent2D.GetNextPathPosition, can trigger a new path calculation. Calling these in your callback to an agent's signal, such as NavigationAgent2D.WaypointReached, can cause infinite recursion. It is recommended to call these methods in the physics step or, alternatively, delay their call until the end of the frame (see ReckfellObject.CallDeferred or ReckfellObject.ConnectFlags.Deferred).

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

NavigationAgent2DConstructor
# NavigationAgent2D
C#
public NavigationAgent2D();

Properties30

AvoidanceEnabledProperty
# AvoidanceEnabled
C#
public bool AvoidanceEnabled { get; set; }

Enables avoidance computation. Submit desired Velocity and apply VelocityComputed output to the body. The flag does not move it or guarantee avoiding every obstacle.

AvoidanceLayersProperty
# AvoidanceLayers
C#
public uint AvoidanceLayers { get; set; }

A bitfield determining the avoidance layers for this NavigationAgent. Other agents with a matching bit on the NavigationAgent2D.AvoidanceMask will avoid this agent.

AvoidanceMaskProperty
# AvoidanceMask
C#
public uint AvoidanceMask { get; set; }

A bitfield determining what other avoidance agents and obstacles this NavigationAgent will avoid when a bit matches at least one of their NavigationAgent2D.AvoidanceLayers.

AvoidancePriorityProperty
# AvoidancePriority
C#
public float AvoidancePriority { get; set; }

The agent does not adjust the velocity for other agents that would match the NavigationAgent2D.AvoidanceMask but have a lower NavigationAgent2D.AvoidancePriority. This in turn makes the other agents with lower priority adjust their velocities even more to avoid collision with this agent.

DebugEnabledProperty
# DebugEnabled
C#
public bool DebugEnabled { get; set; }

If true shows debug visuals for this agent.

DebugPathCustomColorProperty
# DebugPathCustomColor
C#
public Color DebugPathCustomColor { get; set; }

If NavigationAgent2D.DebugUseCustom is true uses this color for this agent instead of global color.

DebugPathCustomLineWidthProperty
# DebugPathCustomLineWidth
C#
public float DebugPathCustomLineWidth { get; set; }

If NavigationAgent2D.DebugUseCustom is true uses this line width for rendering paths for this agent instead of global line width.

DebugPathCustomPointSizeProperty
# DebugPathCustomPointSize
C#
public float DebugPathCustomPointSize { get; set; }

If NavigationAgent2D.DebugUseCustom is true uses this rasterized point size for rendering path points for this agent instead of global point size.

DebugUseCustomProperty
# DebugUseCustom
C#
public bool DebugUseCustom { get; set; }

If true uses the defined NavigationAgent2D.DebugPathCustomColor for this agent instead of global color.

MaxNeighborsProperty
# MaxNeighbors
C#
public int MaxNeighbors { get; set; }

The maximum number of neighbors for the agent to consider.

MaxSpeedProperty
# MaxSpeed
C#
public float MaxSpeed { get; set; }

Avoidance-computation speed limit. Align it with the body desired speed; changing this property does not automatically move the body.

NavigationLayersProperty
# NavigationLayers
C#
public uint NavigationLayers { get; set; }

Mask of surfaces and links for the agent route. Any shared bit admits a region; this is not an all-keys condition. Changing it with an active goal requests a new path, as checked with 1 → 0 → 1.

NeighborDistanceProperty
# NeighborDistance
C#
public float NeighborDistance { get; set; }

The distance to search for other agents.

PathDesiredDistanceProperty
# PathDesiredDistance
C#
public float PathDesiredDistance { get; set; }

Distance tolerance for approaching the next waypoint in map units. Tune for speed and physics step: too small a tolerance can cause overshooting and backtracking.

PathMaxDistanceProperty
# PathMaxDistance
C#
public float PathMaxDistance { get; set; }

The maximum distance the agent is allowed away from the ideal path to the final position. This can happen due to trying to avoid collisions. When the maximum distance is exceeded, it recalculates the ideal path.

PathMetadataFlagsProperty
# PathMetadataFlags
C#
public NavigationPathQueryParameters2D.PathMetadataFlags PathMetadataFlags { get; set; }

Additional information to return with the navigation path.

PathPostprocessingProperty
# PathPostprocessing
C#
public NavigationPathQueryParameters2D.PathPostProcessing PathPostprocessing { get; set; }

The path postprocessing applied to the raw path corridor found by the NavigationAgent2D.PathfindingAlgorithm.

PathReturnMaxLengthProperty
# PathReturnMaxLength
C#
public float PathReturnMaxLength { get; set; }

The maximum allowed length of the returned path in world units. A path will be clipped when going over this length.

PathReturnMaxRadiusProperty
# PathReturnMaxRadius
C#
public float PathReturnMaxRadius { get; set; }

The maximum allowed radius in world units that the returned path can be from the path start. The path will be clipped when going over this radius. Compared to NavigationAgent2D.PathReturnMaxLength, this allows the agent to go that much further, if they need to walk around a corner. Note: This will perform a sphere clip considering only the actual navigation mesh path points with the first path position being the sphere's center.

PathSearchMaxDistanceProperty
# PathSearchMaxDistance
C#
public float PathSearchMaxDistance { get; set; }

The maximum distance a searched polygon can be away from the start polygon before the pathfinding cancels the search for a path to the (possibly unreachable or very far away) target position polygon. In this case the pathfinding resets and builds a path from the start polygon to the polygon that was found closest to the target position so far. A value of 0 or below counts as unlimited. In case of unlimited the pathfinding will search all polygons connected with the start polygon until either the target position polygon is found or all available polygon search options are exhausted.

PathSearchMaxPolygonsProperty
# PathSearchMaxPolygons
C#
public int PathSearchMaxPolygons { get; set; }

The maximum number of polygons that are searched before the pathfinding cancels the search for a path to the (possibly unreachable or very far away) target position polygon. In this case the pathfinding resets and builds a path from the start polygon to the polygon that was found closest to the target position so far. A value of 0 or below counts as unlimited. In case of unlimited the pathfinding will search all polygons connected with the start polygon until either the target position polygon is found or all available polygon search options are exhausted.

PathfindingAlgorithmProperty
# PathfindingAlgorithm
C#
public NavigationPathQueryParameters2D.PathfindingAlgorithmEnum PathfindingAlgorithm { get; set; }

The pathfinding algorithm used in the path query.

RadiusProperty
# Radius
C#
public float Radius { get; set; }

Agent circle radius for avoidance. Does not change a physics collider or rebake navigation geometry for a different character size.

SimplifyEpsilonProperty
# SimplifyEpsilon
C#
public float SimplifyEpsilon { get; set; }

The path simplification amount in world units.

SimplifyPathProperty
# SimplifyPath
C#
public bool SimplifyPath { get; set; }

If true a simplified version of the path will be returned with less critical path points removed. The simplification amount is controlled by NavigationAgent2D.SimplifyEpsilon. 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".

TargetDesiredDistanceProperty
# TargetDesiredDistance
C#
public float TargetDesiredDistance { get; set; }

Tolerance for reaching the original goal and comparing the found endpoint against it. A large value may finish a route earlier than intended.

TargetPositionProperty
# TargetPosition
C#
public Vector2 TargetPosition { get; set; }

Global agent goal. Assignment requests a new route; avoid assigning the same goal every frame without a reason. The agent does not automatically move its parent.

TimeHorizonAgentsProperty
# TimeHorizonAgents
C#
public float TimeHorizonAgents { get; set; }

The minimal amount of time for which this agent's velocities, that are computed with the collision avoidance algorithm, are safe with respect to other agents. The larger the number, the sooner the agent will respond to other agents, but less freedom in choosing its velocities. A too high value will slow down agent movement considerably. Must be positive.

TimeHorizonObstaclesProperty
# TimeHorizonObstacles
C#
public float TimeHorizonObstacles { get; set; }

The minimal amount of time for which this agent's velocities, that are computed with the collision avoidance algorithm, are safe with respect to static avoidance obstacles. The larger the number, the sooner the agent will respond to static avoidance obstacles, but less freedom in choosing its velocities. A too high value will slow down agent movement considerably. Must be positive.

VelocityProperty
# Velocity
C#
public Vector2 Velocity { get; set; }

Desired avoidance velocity in map units per second. Do not multiply it by delta when subsequently supplying it to CharacterBody2D.MoveAndSlide. Computed velocity arrives through VelocityComputed.

Methods80

DistanceToTargetfloat
# DistanceToTarget
C#
public float DistanceToTarget();

Returns the distance to the target position, using the agent's global position. The user must set NavigationAgent2D.TargetPosition in order for this to be accurate.

Returns float
GetAvoidanceEnabledbool
# GetAvoidanceEnabled
C#
public bool GetAvoidanceEnabled();
Returns bool
GetAvoidanceLayerValuebool
# GetAvoidanceLayerValue
C#
public bool GetAvoidanceLayerValue(int layerNumber);

Returns whether or not the specified layer of the NavigationAgent2D.AvoidanceLayers bitmask is enabled, given a layer_number between 1 and 32.

Parameters
NameTypeDefault
layerNumberint—
Returns bool
GetAvoidanceLayersuint
# GetAvoidanceLayers
C#
public uint GetAvoidanceLayers();
Returns uint
GetAvoidanceMaskuint
# GetAvoidanceMask
C#
public uint GetAvoidanceMask();
Returns uint
GetAvoidanceMaskValuebool
# GetAvoidanceMaskValue
C#
public bool GetAvoidanceMaskValue(int maskNumber);

Returns whether or not the specified mask of the NavigationAgent2D.AvoidanceMask bitmask is enabled, given a mask_number between 1 and 32.

Parameters
NameTypeDefault
maskNumberint—
Returns bool
GetAvoidancePriorityfloat
# GetAvoidancePriority
C#
public float GetAvoidancePriority();
Returns float
GetCurrentNavigationPathVector2[]
# GetCurrentNavigationPath
C#
public Vector2[] GetCurrentNavigationPath();

Reads the agent current path array. Does not move the body; points may end at an accessible boundary rather than the original goal.

Returns Vector2[]

Vector2[] containing the current result; check Length before accessing the first or last point.

GetCurrentNavigationPathIndexint
# GetCurrentNavigationPathIndex
C#
public int GetCurrentNavigationPathIndex();

Returns which index the agent is currently on in the navigation path's Vector2[].

Returns int
GetCurrentNavigationResultNavigationPathQueryResult2D
# GetCurrentNavigationResult
C#
public NavigationPathQueryResult2D GetCurrentNavigationResult();

Returns the path query result for the path the agent is currently following.

Returns NavigationPathQueryResult2D
GetDebugEnabledbool
# GetDebugEnabled
C#
public bool GetDebugEnabled();
Returns bool
GetDebugPathCustomColorColor
# GetDebugPathCustomColor
C#
public Color GetDebugPathCustomColor();
Returns Color
GetDebugPathCustomLineWidthfloat
# GetDebugPathCustomLineWidth
C#
public float GetDebugPathCustomLineWidth();
Returns float
GetDebugPathCustomPointSizefloat
# GetDebugPathCustomPointSize
C#
public float GetDebugPathCustomPointSize();
Returns float
GetDebugUseCustombool
# GetDebugUseCustom
C#
public bool GetDebugUseCustom();
Returns bool
GetFinalPositionVector2
# GetFinalPosition
C#
public Vector2 GetFinalPosition();

Updates navigation and returns the current path endpoint, which may differ from the original goal.

Returns Vector2

Last path point, or Vector2.Zero for an empty result. A zero vector alone is not a reliable path-existence test.

GetMaxNeighborsint
# GetMaxNeighbors
C#
public int GetMaxNeighbors();
Returns int
GetMaxSpeedfloat
# GetMaxSpeed
C#
public float GetMaxSpeed();
Returns float
GetNavigationLayerValuebool
# GetNavigationLayerValue
C#
public bool GetNavigationLayerValue(int layerNumber);

Returns whether or not the specified layer of the NavigationAgent2D.NavigationLayers bitmask is enabled, given a layer_number between 1 and 32.

Parameters
NameTypeDefault
layerNumberint—
Returns bool
GetNavigationLayersuint
# GetNavigationLayers
C#
public uint GetNavigationLayers();

Reads the agent query mask. Does not describe body size or avoidance radius.

Returns uint

Current NavigationLayers mask; zero admits no layer for a new path.

GetNavigationMapRid
# GetNavigationMap
C#
public Rid GetNavigationMap();

Returns the explicitly assigned agent map or, without one, its valid parent world map. The locally assigned Entity map can change before the server queue is processed.

Returns Rid

RID of the selected map; may be zero without an assigned map and suitable parent.

GetNeighborDistancefloat
# GetNeighborDistance
C#
public float GetNeighborDistance();
Returns float
GetNextPathPositionVector2
# GetNextPathPosition
C#
public Vector2 GetNextPathPosition();

Updates agent state and returns the next point. Use it in the physics loop for your own parent movement; stop following after route completion.

Returns Vector2

Global path point; with an empty path and a valid parent, returns that parent position rather than a separate error code.

GetPathDesiredDistancefloat
# GetPathDesiredDistance
C#
public float GetPathDesiredDistance();
Returns float
GetPathLengthfloat
# GetPathLength
C#
public float GetPathLength();

Returns the length of the currently calculated path. The returned value is 0.0, if the path is still calculating or no calculation has been requested yet.

Returns float
GetPathMaxDistancefloat
# GetPathMaxDistance
C#
public float GetPathMaxDistance();
Returns float
GetPathMetadataFlagsNavigationPathQueryParameters2D.PathMetadataFlags
# GetPathMetadataFlags
C#
public NavigationPathQueryParameters2D.PathMetadataFlags GetPathMetadataFlags();
Returns NavigationPathQueryParameters2D.PathMetadataFlags
GetPathPostprocessingNavigationPathQueryParameters2D.PathPostProcessing
# GetPathPostprocessing
C#
public NavigationPathQueryParameters2D.PathPostProcessing GetPathPostprocessing();
Returns NavigationPathQueryParameters2D.PathPostProcessing
GetPathReturnMaxLengthfloat
# GetPathReturnMaxLength
C#
public float GetPathReturnMaxLength();
Returns float
GetPathReturnMaxRadiusfloat
# GetPathReturnMaxRadius
C#
public float GetPathReturnMaxRadius();
Returns float
GetPathSearchMaxDistancefloat
# GetPathSearchMaxDistance
C#
public float GetPathSearchMaxDistance();
Returns float
GetPathSearchMaxPolygonsint
# GetPathSearchMaxPolygons
C#
public int GetPathSearchMaxPolygons();
Returns int
GetPathfindingAlgorithmNavigationPathQueryParameters2D.PathfindingAlgorithmEnum
# GetPathfindingAlgorithm
C#
public NavigationPathQueryParameters2D.PathfindingAlgorithmEnum GetPathfindingAlgorithm();
Returns NavigationPathQueryParameters2D.PathfindingAlgorithmEnum
GetRadiusfloat
# GetRadius
C#
public float GetRadius();
Returns float
GetRidRid
# GetRid
C#
public Rid GetRid();

Returns the Rid of this agent on the NavigationServer2D.

Returns Rid
GetSimplifyEpsilonfloat
# GetSimplifyEpsilon
C#
public float GetSimplifyEpsilon();
Returns float
GetSimplifyPathbool
# GetSimplifyPath
C#
public bool GetSimplifyPath();
Returns bool
GetTargetDesiredDistancefloat
# GetTargetDesiredDistance
C#
public float GetTargetDesiredDistance();
Returns float
GetTargetPositionVector2
# GetTargetPosition
C#
public Vector2 GetTargetPosition();
Returns Vector2
GetTimeHorizonAgentsfloat
# GetTimeHorizonAgents
C#
public float GetTimeHorizonAgents();
Returns float
GetTimeHorizonObstaclesfloat
# GetTimeHorizonObstacles
C#
public float GetTimeHorizonObstacles();
Returns float
GetVelocityVector2
# GetVelocity
C#
public Vector2 GetVelocity();
Returns Vector2
IsNavigationFinishedbool
# IsNavigationFinished
C#
public bool IsNavigationFinished();

Updates navigation state and reports whether the current route finished. A partial path can finish too: check IsTargetReached separately.

Returns bool

true for a finished route; not proof that the original goal was reached.

IsTargetReachablebool
# IsTargetReachable
C#
public bool IsTargetReachable();

Updates navigation and compares the found endpoint with the goal using TargetDesiredDistance. Check that a current path exists; this does not guarantee physical-body traversal through the level.

Returns bool

Comparison of the current route endpoint with the goal. Returns false for the checked off-map goal.

IsTargetReachedbool
# IsTargetReached
C#
public bool IsTargetReached();

Reads the stored goal-reached state using TargetDesiredDistance. Path-following logic updates it; this is not a direct physics reachability test.

Returns bool

true when the agent marked the original goal reached; finishing a partial path can leave it false.

SetAvoidanceEnabledvoid
# SetAvoidanceEnabled
C#
public void SetAvoidanceEnabled(bool enabled);
Parameters
NameTypeDefault
enabledbool—
SetAvoidanceLayerValuevoid
# SetAvoidanceLayerValue
C#
public void SetAvoidanceLayerValue(int layerNumber, bool value);

Based on value, enables or disables the specified layer in the NavigationAgent2D.AvoidanceLayers bitmask, given a layer_number between 1 and 32.

Parameters
NameTypeDefault
layerNumberint—
valuebool—
SetAvoidanceLayersvoid
# SetAvoidanceLayers
C#
public void SetAvoidanceLayers(uint layers);
Parameters
NameTypeDefault
layersuint—
SetAvoidanceMaskvoid
# SetAvoidanceMask
C#
public void SetAvoidanceMask(uint mask);
Parameters
NameTypeDefault
maskuint—
SetAvoidanceMaskValuevoid
# SetAvoidanceMaskValue
C#
public void SetAvoidanceMaskValue(int maskNumber, bool value);

Based on value, enables or disables the specified mask in the NavigationAgent2D.AvoidanceMask bitmask, given a mask_number between 1 and 32.

Parameters
NameTypeDefault
maskNumberint—
valuebool—
SetAvoidancePriorityvoid
# SetAvoidancePriority
C#
public void SetAvoidancePriority(float priority);
Parameters
NameTypeDefault
priorityfloat—
SetDebugEnabledvoid
# SetDebugEnabled
C#
public void SetDebugEnabled(bool enabled);
Parameters
NameTypeDefault
enabledbool—
SetDebugPathCustomColorvoid
# SetDebugPathCustomColor
C#
public void SetDebugPathCustomColor(Color color);
Parameters
NameTypeDefault
colorColor—
SetDebugPathCustomLineWidthvoid
# SetDebugPathCustomLineWidth
C#
public void SetDebugPathCustomLineWidth(float lineWidth);
Parameters
NameTypeDefault
lineWidthfloat—
SetDebugPathCustomPointSizevoid
# SetDebugPathCustomPointSize
C#
public void SetDebugPathCustomPointSize(float pointSize);
Parameters
NameTypeDefault
pointSizefloat—
SetDebugUseCustomvoid
# SetDebugUseCustom
C#
public void SetDebugUseCustom(bool enabled);
Parameters
NameTypeDefault
enabledbool—
SetMaxNeighborsvoid
# SetMaxNeighbors
C#
public void SetMaxNeighbors(int maxNeighbors);
Parameters
NameTypeDefault
maxNeighborsint—
SetMaxSpeedvoid
# SetMaxSpeed
C#
public void SetMaxSpeed(float maxSpeed);
Parameters
NameTypeDefault
maxSpeedfloat—
SetNavigationLayerValuevoid
# SetNavigationLayerValue
C#
public void SetNavigationLayerValue(int layerNumber, bool value);

Based on value, enables or disables the specified layer in the NavigationAgent2D.NavigationLayers bitmask, given a layer_number between 1 and 32.

Parameters
NameTypeDefault
layerNumberint—
valuebool—
SetNavigationLayersvoid
# SetNavigationLayers
C#
public void SetNavigationLayers(uint navigationLayers);

Mask of surfaces and links for the agent route. Any shared bit admits a region; this is not an all-keys condition. Changing it with an active goal requests a new path, as checked with 1 → 0 → 1.

Parameters
NameTypeDefault
navigationLayersuint—
navigationLayers

uint mask. Public rooms on layer 1 and a staff passage on layer 2 require mask 3; the passage bit alone does not admit the rooms.

SetNavigationMapvoid
# SetNavigationMap
C#
public void SetNavigationMap(Rid navigationMap);

Assigns the agent Entity query map and submits a map change for its server agent. With an active goal, resets the current result for a new search. This is not geometry-only switching: account for map-isolated avoidance.

Parameters
NameTypeDefault
navigationMapRid—
navigationMap

RID of a live map for the intended navigation type. Wait for a server update after switching; do not use a freed map.

SetNeighborDistancevoid
# SetNeighborDistance
C#
public void SetNeighborDistance(float neighborDistance);
Parameters
NameTypeDefault
neighborDistancefloat—
SetPathDesiredDistancevoid
# SetPathDesiredDistance
C#
public void SetPathDesiredDistance(float desiredDistance);
Parameters
NameTypeDefault
desiredDistancefloat—
SetPathMaxDistancevoid
# SetPathMaxDistance
C#
public void SetPathMaxDistance(float maxSpeed);
Parameters
NameTypeDefault
maxSpeedfloat—
SetPathMetadataFlagsvoid
# SetPathMetadataFlags
C#
public void SetPathMetadataFlags(NavigationPathQueryParameters2D.PathMetadataFlags flags);
Parameters
NameTypeDefault
flagsNavigationPathQueryParameters2D.PathMetadataFlags—
SetPathPostprocessingvoid
# SetPathPostprocessing
C#
public void SetPathPostprocessing(NavigationPathQueryParameters2D.PathPostProcessing pathPostprocessing);
Parameters
NameTypeDefault
pathPostprocessingNavigationPathQueryParameters2D.PathPostProcessing—
SetPathReturnMaxLengthvoid
# SetPathReturnMaxLength
C#
public void SetPathReturnMaxLength(float length);
Parameters
NameTypeDefault
lengthfloat—
SetPathReturnMaxRadiusvoid
# SetPathReturnMaxRadius
C#
public void SetPathReturnMaxRadius(float radius);
Parameters
NameTypeDefault
radiusfloat—
SetPathSearchMaxDistancevoid
# SetPathSearchMaxDistance
C#
public void SetPathSearchMaxDistance(float distance);
Parameters
NameTypeDefault
distancefloat—
SetPathSearchMaxPolygonsvoid
# SetPathSearchMaxPolygons
C#
public void SetPathSearchMaxPolygons(int maxPolygons);
Parameters
NameTypeDefault
maxPolygonsint—
SetPathfindingAlgorithmvoid
# SetPathfindingAlgorithm
C#
public void SetPathfindingAlgorithm(NavigationPathQueryParameters2D.PathfindingAlgorithmEnum pathfindingAlgorithm);
Parameters
NameTypeDefault
pathfindingAlgorithmNavigationPathQueryParameters2D.PathfindingAlgorithmEnum—
SetRadiusvoid
# SetRadius
C#
public void SetRadius(float radius);
Parameters
NameTypeDefault
radiusfloat—
SetSimplifyEpsilonvoid
# SetSimplifyEpsilon
C#
public void SetSimplifyEpsilon(float epsilon);
Parameters
NameTypeDefault
epsilonfloat—
SetSimplifyPathvoid
# SetSimplifyPath
C#
public void SetSimplifyPath(bool enabled);
Parameters
NameTypeDefault
enabledbool—
SetTargetDesiredDistancevoid
# SetTargetDesiredDistance
C#
public void SetTargetDesiredDistance(float desiredDistance);
Parameters
NameTypeDefault
desiredDistancefloat—
SetTargetPositionvoid
# SetTargetPosition
C#
public void SetTargetPosition(Vector2 position);
Parameters
NameTypeDefault
positionVector2—
SetTimeHorizonAgentsvoid
# SetTimeHorizonAgents
C#
public void SetTimeHorizonAgents(float timeHorizon);
Parameters
NameTypeDefault
timeHorizonfloat—
SetTimeHorizonObstaclesvoid
# SetTimeHorizonObstacles
C#
public void SetTimeHorizonObstacles(float timeHorizon);
Parameters
NameTypeDefault
timeHorizonfloat—
SetVelocityvoid
# SetVelocity
C#
public void SetVelocity(Vector2 velocity);
Parameters
NameTypeDefault
velocityVector2—
SetVelocityForcedvoid
# SetVelocityForced
C#
public void SetVelocityForced(Vector2 velocity);

Replaces the internal velocity in the collision avoidance simulation with NavigationAgent2D.Velocity. When an agent is teleported to a new position this function should be used in the same frame. If called frequently this function can get agents stuck.

Parameters
NameTypeDefault
velocityVector2—

Signals and events6

LinkReachedEvent
# LinkReached
C#
public event NavigationAgent2D.LinkReachedEventHandler LinkReached;

Signals that the agent reached a navigation link. Emitted when the agent moves within NavigationAgent2D.PathDesiredDistance of the next position of the path when that position is a navigation link. The details dictionary may contain the following keys depending on the value of NavigationAgent2D.PathMetadataFlags:

  • position: The start position of the link that was reached.
  • type: Always NavigationPathQueryResult2D.PathSegmentType.Link.
  • rid: The Rid of the link.
  • owner: The object which manages the link (usually NavigationLink2D).
  • link_entry_position: If owner is available and the owner is a NavigationLink2D, it will contain the global position of the link's point the agent is entering.
  • link_exit_position: If owner is available and the owner is a NavigationLink2D, it will contain the global position of the link's point which the agent is exiting.
Handler parameters
NameTypeDefault
detailsReckfell.Collections.Dictionary—
NavigationFinishedEvent
# NavigationFinished
C#
public event Action NavigationFinished;

Signals that the agent's navigation has finished. If the target is reachable, navigation ends when the target is reached. If the target is unreachable, navigation ends when the last waypoint of the path is reached. This signal is emitted only once per loaded path. This signal will be emitted just after NavigationAgent2D.TargetReached when the target is reachable.

PathChangedEvent
# PathChanged
C#
public event Action PathChanged;

Emitted when the agent had to update the loaded path:

  • because path was previously empty.
  • because navigation map has changed.
  • because agent pushed further away from the current path segment than the NavigationAgent2D.PathMaxDistance.
TargetReachedEvent
# TargetReached
C#
public event Action TargetReached;

Signals that the agent reached the target, i.e. the agent moved within NavigationAgent2D.TargetDesiredDistance of the NavigationAgent2D.TargetPosition. This signal is emitted only once per loaded path. This signal will be emitted just before NavigationAgent2D.NavigationFinished when the target is reachable. It may not always be possible to reach the target but it should always be possible to reach the final position. See NavigationAgent2D.GetFinalPosition.

VelocityComputedEvent
# VelocityComputed
C#
public event NavigationAgent2D.VelocityComputedEventHandler VelocityComputed;

Notifies when the collision avoidance velocity is calculated. Emitted every update as long as NavigationAgent2D.AvoidanceEnabled is true and the agent has a navigation map.

Handler parameters
NameTypeDefault
safeVelocityVector2—
WaypointReachedEvent
# WaypointReached
C#
public event NavigationAgent2D.WaypointReachedEventHandler WaypointReached;

Signals that the agent reached a waypoint. Emitted when the agent moves within NavigationAgent2D.PathDesiredDistance of the next position of the path. The details dictionary may contain the following keys depending on the value of NavigationAgent2D.PathMetadataFlags:

  • position: The position of the waypoint that was reached.
  • type: The type of navigation primitive (region or link) that contains this waypoint.
  • rid: The Rid of the containing navigation primitive (region or link).
  • owner: The object which manages the containing navigation primitive (region or link).
Handler parameters
NameTypeDefault
detailsReckfell.Collections.Dictionary—
Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.