Version: Unity 6.5 (6000.5)
LanguageEnglish
  • C#

NavNode.operator !=

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

public static bool operator !=(NavNode left, NavNode right);

Parameters

Parameter Description
left The NavNode on the left side of the operator.
right The NavNode on the right side of the operator.

Returns

bool true if the two NavNode values reference different nodes or differ in null state, false otherwise.

Description

Determines whether two NavNode objects refer to different NavMesh nodes.

This operator is a syntactic shortcut equivalent to negating the result of NavNode.Equals. Use it inside expressions where the != syntax is more concise than an explicit method call. A null NavNode is considered different from any non-null one.

Additional resources: NavNode.IsNull

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

public class NavNodeNotEqualOperatorExample : MonoBehaviour
{
    public Transform other;

    void Update()
    {
        using NavWorld world = NavWorld.GetDefaultWorld();
        NavLocation a = world.MapLocation(transform.position, Vector3.one, 0);
        NavLocation b = world.MapLocation(other.position, Vector3.one, 0);

        if (a.node != b.node)
            Debug.DrawLine(a.position, b.position, Color.red);
    }
}