Version: Unity 6.5 (6000.5)
LanguageEnglish
  • C#

NavNode

struct in Unity.AI.Navigation.LowLevel

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Represents a compact identifier for the data of a navigation graph node.

It is used in NavWorld operations for pinpointing and accessing relevant nodes in the NavMesh or NavMesh Links. Each node can be used by only one type of agent.

This identifier becomes invalid once the node is removed from the NavMesh, either by completely removing the surface or by modifying the surface in the node's immediate vicinity.

For more information about the surfaces that nodes describe, refer to Walkable Areas.

Additional resources: NavWorld.IsValid

using UnityEngine;
using Unity.AI.Navigation.LowLevel;

public class NavNodeExample : MonoBehaviour
{
    void Update()
    {
        using NavWorld world = NavWorld.GetDefaultWorld();
        NavLocation location = world.MapLocation(transform.position, Vector3.one, 0);
        if (!world.IsValid(location))
            return;

        // The NavNode is the handle through which NavWorld looks up the underlying polygon or link.
        NavNode node = location.node;
        NavNodeType type = world.GetNodeType(node);
        int agentTypeId = world.GetAgentTypeIdForNode(node);
        Debug.Log($"Standing on a {type} node baked for agent type {agentTypeId}.");
    }
}

Public Methods

Method Description
EqualsDetermines whether this NavNode object refers to the same navigation node as another.
GetHashCodeObtains the hash code of this NavNode for use in collections.
IsNullDetermines whether this NavNode is empty of any information.

Operators

Operator Description
operator !=Determines whether two NavNode objects refer to different NavMesh nodes.
operator ==Determines whether two NavNode objects refer to the same NavMesh node.