Equals
Checks whether two NavLocation objects represent the same position on the same NavMesh node.
Read time 2 minutesLast updated 22 days ago
Definition
- Type: Method
- Namespace: Unity.AI.Navigation.LowLevel
- Assembly: UnityEngine.AIModule
Equals(NavLocation)
Checks whether two NavLocation objects represent the same position on the same NavMesh node.
public bool Equals(NavLocation other)
Parameters
A NavLocation to compare this one with.
Returns
Type | Description |
|---|---|
| bool | |
Remarks
The comparison checks the node identifier and the exact position coordinates. Two NavLocation values that share the same node but have slightly different positions are considered different. Use this method to compare NavLocation values instead of relying on reference equality.
Examples
using UnityEngine;using Unity.AI.Navigation.LowLevel;public class NavLocationEqualsExample : MonoBehaviour{ void Update() { using NavWorld world = NavWorld.GetDefaultWorld(); NavLocation a = world.MapLocation(transform.position, Vector3.one, 0); NavLocation b = world.MapLocation(transform.position, Vector3.one, 0); if (a.Equals(b)) Debug.Log("Both samples landed on the same node and position."); }}
Equals(Object)
Checks whether two NavLocation objects represent the same position on the same NavMesh node.
public override bool Equals(object obj)
Parameters
An object to interpret as a NavLocation and to compare this one with.
Returns
Type | Description |
|---|---|
| bool | |
Remarks
The comparison checks the node identifier and the exact position coordinates. Two NavLocation values that share the same node but have slightly different positions are considered different. Use this method to compare NavLocation values instead of relying on reference equality.
Examples
using UnityEngine;using Unity.AI.Navigation.LowLevel;public class NavLocationEqualsExample : MonoBehaviour{ void Update() { using NavWorld world = NavWorld.GetDefaultWorld(); NavLocation a = world.MapLocation(transform.position, Vector3.one, 0); NavLocation b = world.MapLocation(transform.position, Vector3.one, 0); if (a.Equals(b)) Debug.Log("Both samples landed on the same node and position."); }}