NavMeshAgentclass

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

object→Component→NavMeshAgent
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public sealed class Sandbox.NavMeshAgent : Sandbox.Component

Constructors1

Showing 1 constructors

Methods7

Showing 7 methods

public void CompleteLinkTraversal()PUBLIC

Ends custom link traversal at the current AgentPosition and resumes navigation.

Returns:void—

public Vector3 GetLookAhead(float distance)PUBLIC

ParameterTypeDescription
distancefloat—
Returns:Vector3—

public void MoveTo(Vector3 targetPosition)PUBLIC

ParameterTypeDescription
targetPositionVector3—
Returns:void—

public void SetAgentPosition(Vector3 position)PUBLIC

Explicitly repositions the simulated agent. Runtime GameObject transforms do not move it.

ParameterTypeDescription
positionVector3—
Returns:void—

public void SetPath(Sandbox.Navigation.NavMeshPath path)PUBLIC

Assigns a path calculated on this navmesh. The start must project onto the path's first polygon.

ParameterTypeDescription
pathNavMeshPath—
Returns:void—

public void Stop()PUBLIC

Returns:void—

Properties20

Showing 20 properties

public float Sandbox.NavMeshAgent.Acceleration { get; set; }PUBLICGETSET

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 `Sandbox.NavMeshAgent.MaxSpeed`.

Returns:float—

public Vector3 Sandbox.NavMeshAgent.AgentPosition { get; set; }PUBLICGETSET

The current simulated position, including when UpdatePosition is false.

Returns:Vector3—

public bool Sandbox.NavMeshAgent.AllowDefaultArea { get; set; }PUBLICGETSET

Is the agent allowed to travel on the default area?

Returns:bool—

public System.Collections.Generic.HashSet`1<Sandbox.Engine.Resources.NavMeshAreaDefinition> Sandbox.NavMeshAgent.AllowedAreas { get; set; }PUBLICGETSET

What areas the agent is allowed to travel on. If empty, all areas are allowed.

Returns:HashSet<NavMeshAreaDefinition>—

public System.Collections.Generic.HashSet`1<Sandbox.Engine.Resources.NavMeshAreaDefinition> Sandbox.NavMeshAgent.ForbiddenAreas { get; set; }PUBLICGETSET

What areas the agent is not allowed to travel on. If empty, no areas are forbidden.

Returns:HashSet<NavMeshAreaDefinition>—

public float Sandbox.NavMeshAgent.Height { get; set; }PUBLICGETSET

Returns:float—

public bool Sandbox.NavMeshAgent.IsNavigating { get; set; }PUBLICGETSET

Returns:bool—

public System.Action Sandbox.NavMeshAgent.LinkEnter { get; set; }PUBLICGETSET

Returns:Action—

public System.Action Sandbox.NavMeshAgent.LinkExit { get; set; }PUBLICGETSET

Returns:Action—

public float Sandbox.NavMeshAgent.MaxSpeed { get; set; }PUBLICGETSET

Returns:float—

public float Sandbox.NavMeshAgent.Radius { get; set; }PUBLICGETSET

Returns:float—

public float Sandbox.NavMeshAgent.Separation { get; set; }PUBLICGETSET

Gets or sets the separation factor used to control how strongly agents avoid crowding each other.

Returns:float—

public bool Sandbox.NavMeshAgent.SyncAgentPosition { get; set; }PUBLICGETSETOBSOLETE

Obsolete: This API member is obsolete.

Returns:bool—

public System.Nullable`1<Vector3> Sandbox.NavMeshAgent.TargetPosition { get; set; }PUBLICGETSET

The requested target, or null when stopped.

Returns:Nullable<Vector3>—

public bool Sandbox.NavMeshAgent.UpdatePosition { get; set; }PUBLICGETSETPER-FRAME

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.

Returns:bool—

public bool Sandbox.NavMeshAgent.UpdateRotation { get; set; }PUBLICGETSETPER-FRAME

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.

Returns:bool—

On this page

Constructorspublic NavMeshAgent()Methodspublic System.Void CompleteLinkTraversal()public Vector3 GetLookAhead(System.Single distance)public Sandbox.Navigation.NavMeshPath GetPath()public System.Void MoveTo(Vector3 targetPosition)public System.Void SetAgentPosition(Vector3 position)public System.Void SetPath(Sandbox.Navigation.NavMeshPath path)public System.Void Stop()Propertiespublic System.Single Sandbox.NavMeshAgent.Acceleration { get; set; }public Vector3 Sandbox.NavMeshAgent.AgentPosition { get; set; }public System.Boolean Sandbox.NavMeshAgent.AllowDefaultArea { get; set; }public System.Collections.Generic.HashSet`1<Sandbox.Engine.Resources.NavMeshAreaDefinition> Sandbox.NavMeshAgent.AllowedAreas { get; set; }public System.Boolean Sandbox.NavMeshAgent.AutoTraverseLinks { get; set; }public System.Collections.Generic.HashSet`1<Sandbox.Engine.Resources.NavMeshAreaDefinition> Sandbox.NavMeshAgent.ForbiddenAreas { get; set; }public System.Single Sandbox.NavMeshAgent.Height { get; set; }public System.Boolean Sandbox.NavMeshAgent.IsNavigating { get; set; }public System.Boolean Sandbox.NavMeshAgent.IsTraversingLink { get; set; }public System.Action Sandbox.NavMeshAgent.LinkEnter { get; set; }public System.Action Sandbox.NavMeshAgent.LinkExit { get; set; }public System.Single Sandbox.NavMeshAgent.MaxSpeed { get; set; }public System.Single Sandbox.NavMeshAgent.Radius { get; set; }public System.Single Sandbox.NavMeshAgent.Separation { get; set; }public System.Boolean Sandbox.NavMeshAgent.SyncAgentPosition { get; set; }public System.Nullable`1<Vector3> Sandbox.NavMeshAgent.TargetPosition { get; set; }public System.Boolean Sandbox.NavMeshAgent.UpdatePosition { get; set; }public System.Boolean Sandbox.NavMeshAgent.UpdateRotation { get; set; }public Vector3 Sandbox.NavMeshAgent.Velocity { get; set; }public Vector3 Sandbox.NavMeshAgent.WishVelocity { get; set; }Metadata