NavMeshAgent.CalculatePath(Vector3 targetPosition, NavMeshPath path)
Calculate a path to a specified point and store the resulting path.
Parameters:
Name | Type | Description |
---|---|---|
targetPosition | Vector3 | The final position of the path requested. |
path | NavMeshPath | The 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.