Skip to main content

NavMeshAgent.CalculatePath(Vector3 targetPosition, NavMeshPath path)

Calculate a path to a specified point and store the resulting path.

Parameters:

NameTypeDescription
targetPositionVector3The final position of the path requested.
pathNavMeshPathThe resulting path.

Usage

---@type NavMeshAgent
local navmeshagent;

---@type Vector3
local targetPosition;

---@type NavMeshPath
local path;


navmeshagent.CalculatePath(targetPosition, path)

Extra Detail

This function can be used to plan a path ahead of time to avoid a delay in gameplay when the path is needed. Another use is to check if a target position is reachable before moving the agent.