Skip to main content

NavMeshAgent.SamplePathPosition(number areaMask, number maxDistance)

Sample a position along the current path.

Parameters:

NameTypeDescription
areaMasknumberA bitfield mask specifying which NavMesh areas can be passed when tracing the path.
maxDistancenumberTerminate scanning the path at this distance.

Returns:

typeDescription
booleanTrue if terminated before reaching the position at maxDistance, false otherwise.
NavMeshHitthe properties of the resulting location.

Usage

---@type NavMeshAgent
local navmeshagent;

---@type number
local areaMask;

---@type number
local maxDistance;


local val0, val1 = navmeshagent.SamplePathPosition(areaMask, maxDistance)

Extra Detail

This function looks ahead a specified distance along the current path. Details of the mesh at that position are then returned in a NavMeshHit object. This could be used, for example, to check the type of surface that lies ahead before the character gets there - a character could raise his gun above his head if he is about to wade through water, say.