operator ==(NavNode, NavNode)
Returns true if two NavNode values refer to the same NavMesh node.
Read time 1 minuteLast updated 8 hours ago
Definition
- Type: Operator
- Namespace: Unity.AI.Navigation.LowLevel
- Assembly: UnityEngine.AIModule
public static bool operator ==(NavNode left, NavNode right)
Parameters
Returns
Type | Description |
|---|---|
| bool | |
Remarks
This operator is a syntactic shortcut equivalent to calling NavNode.Equals. Use it inside expressions where the syntax is more concise than an explicit method call. Two null NavNode values are considered equal.
==Additional Resources: NavNode.IsNull
Examples
using UnityEngine;using Unity.AI.Navigation.LowLevel;// Move the GameObject and see how far it travels inside the closest NavMesh nodepublic class NavNodeEqualOperatorExample : MonoBehaviour{ NavNode m_Cached; Vector3 m_CachedEntryPoint; void Update() { using NavWorld world = NavWorld.GetDefaultWorld(); NavLocation current = world.MapLocation(transform.position, 5f * Vector3.one, -1); if (!world.IsValid(current)) { Debug.DrawRay(transform.position, Vector3.up, Color.red); return; } if (current.node == m_Cached) { // Still on the same node, so show how far it has travelled across it. Debug.DrawLine(m_CachedEntryPoint, current.position, Color.yellow); Debug.DrawLine(current.position, transform.position, Color.grey); return; } m_Cached = current.node; m_CachedEntryPoint = current.position; }}