Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


NavQueryStatus

Bit flags representing the resulting state of NavWorld operations.
Read time 2 minutesLast updated 13 days ago

Definition

[Flags]public enum NavQueryStatus

Remarks

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.

Examples

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(); }}

Fields

Value

Description

FailureThe NavWorld operation didn't complete successfully and produced no usable result.
InProgressThe NavWorld operation has started but hasn't yet finished and requires additional calls to advance.
InvalidParameterA parameter didn't contain valid information, useful for carrying out the NavMesh query.
MaxNodesToVisitExceededQuery ran out of node stack space during a search.
MoreDataAvailableThe output buffer provided to the query was too small to hold all the results.
PartialResultQuery didn't reach the end location, returning best guess.
StatusDetailMaskBitmask that has 0 set for the Success, Failure and InProgress bits and 1 set for all the other flags.
SuccessThe NavWorld operation completed successfully and produced a valid result for the caller to consume.