IsNull()
Determines whether this NavNode is empty of any information.
Read time 1 minuteLast updated 8 hours ago
Definition
- Type: Method
- Namespace: Unity.AI.Navigation.LowLevel
- Assembly: UnityEngine.AIModule
public readonly bool IsNull()
Returns
Type | Description |
|---|---|
| bool | |
Remarks
A null NavNode is the default value of the struct and represents the absence of a reference to any node. This is distinct from a that once referenced a real node that has since been removed; in that case still returns . Use NavWorld.IsValid to check whether a non-null node is currently active in the NavMesh.
NavNodeIsNullfalseExamples
using UnityEngine;using UnityEngine.AI;using Unity.AI.Navigation.LowLevel;// Move the gameobject until it maps to a NavMesh polygon whose area type is not excludedpublic class NavNodeIsNullExample : MonoBehaviour{ public int excludedAreaType = 0; NavLocation m_Stored; void Update() { using NavWorld world = NavWorld.GetDefaultWorld(); if (m_Stored.node.IsNull()) { int validAreaTypes = NavMesh.AllAreas & ~(1 << System.Math.Clamp(excludedAreaType, 0, 31)); NavLocation location = world.MapLocation(transform.position, 0.3f * Vector3.one, -1, validAreaTypes); if (world.IsValid(location)) { m_Stored = location; } Debug.DrawRay(transform.position, Vector3.up, Color.red); return; } Color statusColor = world.IsValid(m_Stored) ? Color.green : Color.yellow; Debug.DrawRay(m_Stored.position, Vector3.up, statusColor); Debug.DrawLine(transform.position, m_Stored.position, Color.gray); } void OnDisable() { m_Stored = new NavLocation(); }}