Api Sandbox NavMeshAgent
class

NavMeshAgent

public sealed class NavMeshAgent : Component

An agent that can navigate the navmesh defined in the scene.

Constructors

NavMeshAgent()

Properties

Name Type Description
Height Single
Radius Single
MaxSpeed Single
Acceleration Single The maximum acceleration a agent can have. This is how fast the agent can change its velocity. If you want snappy movement this should be as high or higher than MaxSpeed.
UpdatePosition Boolean Set the Position of the GameObject to the agent position every frame. You can turn this off and handle it yourself by using the AgentPosition property.
UpdateRotation Boolean This will simply face the direction it is moving. It is not configurable on purpose, so you should really turn this off and be doing this yourself if you need it to do anything specific.
AllowedAreas HashSet<NavMeshAreaDefinition> What areas the agent is allowed to travel on. If empty, all areas are allowed.
ForbiddenAreas HashSet<NavMeshAreaDefinition> What areas the agent is not allowed to travel on. If empty, no areas are forbidden.
AllowDefaultArea Boolean Is the agent allowed to travel on the default area?
AutoTraverseLinks Boolean Should the agent automatically traverse links when it reaches them? Or do you want to implement your own link traversal logic?
Separation Single Gets or sets the separation factor used to control how strongly agents avoid crowding each other.
AgentPosition Vector3 Updated with the agent's position, even if UpdatePosition is false
TargetPosition Vector3? Gets the current target position for the agent, if one is set.
Velocity Vector3
WishVelocity Vector3 The velocity the agent would like to move at, you can pass this into a PlayerController.
IsNavigating Boolean Returns true if the agent is currently navigating to a target.
SyncAgentPosition Boolean
LinkEnter Action Emitted when the agent enters a link.
LinkExit Action Emitted when the agent exits a link.
IsTraversingLink Boolean Returns true if the agent is currently traversing a link.

Methods

Void SetAgentPosition(Vector3 position)

If you want to move the agent from one position to another

Void MoveTo(Vector3 targetPosition)

Navigate to the position

Void SetPath(NavMeshPath path)

Assigns a precalculated path for the agent to follow. The agent will attempt to follow the path, but may adjust its movement to avoid obstacles or other agents. If the path becomes invalid during navigation, it may be recalculated completely.

NavMeshPath GetPath()

Returns the agent's current path as a NavMeshPath. This is not free, so avoid calling it every frame.

returns — A NavMeshPath containing the agent's current path information.
Void Stop()

Stop moving, or whatever we're doing

Void CompleteLinkTraversal()

Finish link traversal, must be called after traversing a link if AutoTraverseLinks is false.

Vector3 GetLookAhead(Single distance)

Get a point on the current path, distance away from here. This is a simplified path so only includes the first few corners.

Fields

Name Type Description
CurrentLinkTraversal LinkTraversalData? Information about the current link traversal.
Assembly: Sandbox.Engine Namespace: Sandbox Full Name: Sandbox.NavMeshAgent