| Parameter | Description |
|---|---|
| node | The identifier of the NavMesh node to get the area type index for. |
int
An integer from 0 to 31 that identifies the area type of the node.
Returns 1, the index of the built-in Not Walkable area, when the node isn't valid in this NavWorld.
Obtains the area type index assigned to the specified NavMesh node.
You define area types in the Navigation settings, and an index from 0 to 31 identifies each one. Use the returned value with NavMesh.GetAreaCost to look up the traversal cost for that area.
For more information about defining area types, refer to Areas and Costs.
using UnityEngine; using UnityEngine.AI; using Unity.AI.Navigation.LowLevel; public class AreaIndexForNodeExample : MonoBehaviour { void Update() { using NavWorld world = NavWorld.GetDefaultWorld(); NavLocation location = world.MapLocation(transform.position, Vector3.one, 0); if (!world.IsValid(location)) return; int areaIndex = world.GetAreaIndexForNode(location.node); float traversalCost = NavMesh.GetAreaCost(areaIndex); Debug.Log($"Node has area index {areaIndex} with traversal cost {traversalCost}"); } }