s&box docs

public sealed class Sandbox.NavMeshAgent : Sandbox.Component

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

Broader workflow and conceptual references connected to this API.

Constructors

Showing 1 constructors

Methods

Showing 7 methods

public void CompleteLinkTraversal()

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

public Vector3 GetLookAhead(float distance)

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

public Sandbox.Navigation.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.

public void MoveTo(Vector3 targetPosition)

Navigate to the position

public void SetAgentPosition(Vector3 position)

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

public void SetPath(Sandbox.Navigation.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.

public void Stop()

Stop moving, or whatever we're doing

Properties

Showing 20 properties

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

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`.

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

Updated with the agent's position, even if UpdatePosition is false

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

Is the agent allowed to travel on the default area?

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

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

Should the agent automatically traverse links when it reaches them? Or do you want to implement your own link traversal logic?

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

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

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

Returns true if the agent is currently navigating to a target.

Returns true if the agent is currently traversing a link.

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

Emitted when the agent enters a link.

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

Emitted when the agent exits a link.

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

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

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

Obsolete: This API member is obsolete.

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

Gets the current target position for the agent, if one is set.

public bool Sandbox.NavMeshAgent.UpdatePosition { get; set; }

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.

public bool Sandbox.NavMeshAgent.UpdateRotation { get; set; }

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.

public Vector3 Sandbox.NavMeshAgent.WishVelocity { get; set; }

The velocity the agent would like to move at, you can pass this into a PlayerController.

Metadata

FieldValue
NamespaceSandbox
Typeclass
AssemblySandbox.Engine
Doc IDT:Sandbox.NavMeshAgent

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