Bit flags representing the resulting state of NavWorld operations.
The main values are Success, Failure and InProgress. A status usually has only one of these main flags set. Unity sets the secondary flags (details) when it encounters specific issues during the operation. Apply StatusDetailMask as a bitmask to retain only the active secondary flags.
using Unity.AI.Navigation.LowLevel; using Unity.Collections; using UnityEngine; public class NavQueryStatusDetailMaskExample : MonoBehaviour { public Transform target; NavWorld m_World; NavQueryBuffer m_Buffer; void OnEnable() { m_World = NavWorld.GetDefaultWorld(); // Deliberately small so the query is likely to run out of node budget and set a detail flag. m_Buffer = new NavQueryBuffer(m_World, Allocator.Persistent, 4); } void Update() { NavLocation start = m_World.MapLocation(transform.position, Vector3.one, 0); NavLocation end = m_World.MapLocation(target.position, Vector3.one, 0); if (!m_World.IsValid(start) || !m_World.IsValid(end)) return; NavQueryStatus status = m_World.BeginFindPath(m_Buffer, start, end); if ((status & NavQueryStatus.InProgress) != 0) status = m_World.ContinueFindPath(m_Buffer, 10, out int _); // Keep only the detail flags (Success, Failure and InProgress bits are cleared). NavQueryStatus details = status & NavQueryStatus.StatusDetailMask; // Keep only the main status flag by masking off every detail bit. NavQueryStatus main = status & ~NavQueryStatus.StatusDetailMask; if ((details & NavQueryStatus.MaxNodesToVisitExceeded) != 0) Debug.Log("The pathfinding buffer was too small; increase maxNodesToVisit."); Debug.Log($"Main flag: {main}, detail flags: {details}"); } void OnDisable() { m_Buffer.Dispose(); m_World.Dispose(); } }
| Property | Description |
|---|---|
| Failure | The NavWorld operation didn't complete successfully and produced no usable result. |
| Success | The NavWorld operation completed successfully and produced a valid result for the caller to consume. |
| InProgress | The NavWorld operation has started but hasn't yet finished and requires additional calls to advance. |
| StatusDetailMask | Bitmask that has 0 set for the Success, Failure and InProgress bits and 1 set for all the other flags. |
| InvalidParameter | A parameter didn't contain valid information, useful for carrying out the NavMesh query. |
| MoreDataAvailable | The output buffer provided to the query was too small to hold all the results. |
| MaxNodesToVisitExceeded | Query ran out of node stack space during a search. |
| PartialResult | Query didn't reach the end location, returning best guess. |