Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


IsNull()

Determines whether this NavNode is empty of any information.
Read time 1 minuteLast updated 10 days ago

Definition

public readonly bool IsNull()

Returns

Type

Description

bool
true
if the NavNode has been created empty and has never pointed to any node in the NavMesh, or
false
otherwise.

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 NavNode that once referenced a real node that has since been removed; in that case NavNode.IsNull still returns false. Use NavWorld.IsValid to check whether a non-null node is currently active in the NavMesh.

Examples

using UnityEngine;using Unity.AI.Navigation.LowLevel;public class NavNodeIsNullExample : MonoBehaviour{ NavNode m_Stored; void Update() { // Default-initialized NavNode values are null until you assign one from a NavWorld query. if (m_Stored.IsNull()) { using NavWorld world = NavWorld.GetDefaultWorld(); NavLocation location = world.MapLocation(transform.position, Vector3.one, 0); if (world.IsValid(location)) m_Stored = location.node; } }}