AI Navigation Component
The AI Navigation component (plAiNavigationComponent) finds a path on a runtime navmesh and steers its owner toward a world-space destination. It supports crowd avoidance, character-controller movement, root-motion integration, and off-mesh links.
Set up a character
- Verify the scene with a Navmesh Path Test.
- Add AI Navigation to the character's moving game object, with its origin at the feet. Select the same
NavmeshConfigandPathSearchConfigas the successful test. - Choose a
MovementModeand configure the ground-queryCollisionLayer. - Call
SetDestination(destination, allowPartialPaths)from gameplay code or use an Ai Navigate To state. - Enable
PrintState,VisPathLine, andVisTargetinDebugFlagswhile testing.
With partial paths disabled, an unreachable destination produces Failed. With them enabled, the agent may travel only as far as the available route allows. Moving includes waiting for path computation; it does not guarantee visible movement every frame.
Movement modes
| Mode | Setup and behavior |
|---|---|
DirectTransform | Writes the owner's position and rotation. Set ApplySteering to false to read the computed steering transform and apply movement yourself. |
PhysicsCharacter | Sends plMsgMoveCharacterController to the owner. Add a compatible character controller and match CCWalkSpeed, CCRunSpeed, and CCRotateSpeed to its settings. |
RootMotion | Writes normalized movement intent to the MoveForwards blackboard entry, applies steering rotation, and corrects positional drift. Requires a shared blackboard and animation setup that actually applies root motion. |
ApplySteering controls transform application in DirectTransform mode; it is not a global disable switch for the other modes. Root-motion correction is controlled by AI.Navigation.DriftCorrection.
In direct and root-motion modes, physics queries place the feet on solid ground. FootRadius is the ground-query footprint, not the body radius used for avoidance. Keep it wide enough to span small floor gaps but narrow enough to avoid hovering beside ledges. PhysicsCharacter delegates ground contact to the character controller.
Crowd avoidance
CrowdAvoidance enables local steering around registered agents. AgentRadius defines the body footprint and AvoidanceQuality controls the cost of the avoidance calculation. Navigation components register themselves; add an AI Crowd Agent component to the player or another object that moves through input, physics, or animation. That component exposes Radius and makes the object visible to avoidance without moving it.
Crowd steering and the navmesh agent radius solve different problems: the navmesh radius determines clearance from level geometry; the component radius determines clearance between moving agents. Avoidance does not replace physical collision handling.
Component properties
| Property | Purpose |
|---|---|
NavmeshConfig, PathSearchConfig | Walkable geometry configuration and ground-type permissions/costs. |
Speed | Target movement speed. |
Acceleration, Deceleration | How quickly movement accelerates and brakes. |
ReachedDistance | Distance at which the destination counts as reached. |
FootRadius, CollisionLayer, FallHeight | Ground detection and the distance below the feet that counts as falling. |
CrowdAvoidance, AgentRadius, AvoidanceQuality | Local avoidance settings. |
MovementMode, ApplySteering | How computed movement is applied; see the modes above. |
CCWalkSpeed, CCRunSpeed, CCRotateSpeed | Character-controller settings used to convert desired velocity into controller input. |
LinkTraverseSpeed | Speed of built-in off-mesh link traversal. |
DebugFlags | PrintState, VisPathCorridor, VisPathLine, and VisTarget. |
Exposed functions and states
SetDestinationstarts navigation;CancelNavigationcancels it. Cancellation does not cancel an ongoing fall.StopWalking(withinDistance)requests stopping within the supplied distance.TurnTowardsandGetTurnAngleTowardsoperate on a world-space XY target.EnsureNavMeshSectorAvailable(center, radius)requests an area and returns whether it is ready. Retry on a later frame when false.FindRandomPointAroundCircleandRaycastNavMeshquery the navmesh. A random point can fall outside the requested circle when a large polygon overlaps it.GetSteeringPositionandGetSteeringRotationexpose the computed transform.FinishLinkTraversalresumes navigation after game code finishes a link traversal.
GetState() reports Idle, Moving, Turning, Falling, Fallen, Failed, or TraversingLink. Fallen means an airborne character has landed; it is not the destination-reached state. Failure reporting does not distinguish every cause, so use the path test and debugging tools to inspect geometry and route availability.