---
title: GetHashCode()
product: Unity Editor
version: '7000.0'
latest_version: '7000.0'
status: This page documents version 7000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/ai/navigation/lowlevel/navnode/gethashcode
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/ai/navigation/lowlevel/navnode/gethashcode.md
last_updated: 2026-11-30
generated_at: 2026-12-01T01:33:47.019Z
locale: en-us
---

# GetHashCode()

> Obtains the hash code of this NavNode for use in collections.

## Definition

* **Type:** Method
* **Namespace:** [Unity.AI.Navigation.LowLevel](/engine/7000.0/script-reference/unity/ai/navigation/lowlevel.md)
* **Assembly:** [UnityEngine.AIModule](/engine/7000.0/script-reference/modules/unityengine-aimodule.md)

```csharp
public override readonly int GetHashCode()
```

### Returns

| Type                                                       | Description                                                                                 |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The hash code derived from the node identifier, suitable for use in hash-based collections. |

### Remarks

The returned value is derived from the internal identifier of the [NavNode](/engine/7000.0/script-reference/unity/ai/navigation/lowlevel/navnode.md) and is suitable for storing nodes in hash-based collections such as Dictionary\_2 or HashSet\_1. Two `NavNode` values that compare equal through [NavNode.Equals](/engine/7000.0/script-reference/unity/ai/navigation/lowlevel/navnode/equals.md) also produce the same hash code.

### Examples

```csharp
using System.Collections.Generic;
using UnityEngine;
using Unity.AI.Navigation.LowLevel;

// Move the gameobject and see where each NavMesh polygon gets visited first
public class NavNodeHashExample : MonoBehaviour
{
    readonly Dictionary<NavNode, Vector3> m_FirstSeenAt = new Dictionary<NavNode, Vector3>();

    void Update()
    {
        using NavWorld world = NavWorld.GetDefaultWorld();
        NavLocation location = world.MapLocation(transform.position, 5f * Vector3.one, -1);
        if (!world.IsValid(location))
        {
            Debug.DrawRay(transform.position, Vector3.up, Color.red);
            return;
        }

        if (!m_FirstSeenAt.ContainsKey(location.node))
            m_FirstSeenAt.Add(location.node, location.position);

        foreach (KeyValuePair<NavNode, Vector3> visited in m_FirstSeenAt)
        {
            bool stillValid = world.IsValid(visited.Key);
            Debug.DrawRay(visited.Value, 0.3f * Vector3.up, stillValid ? Color.cyan : Color.red);
        }
    }

    void OnEnable()
    {
        m_FirstSeenAt.Clear();
    }
}
```
