---
tags:
    - "Navigation"
    - "NavMesh"
    - "AI"
    - "Agent"
    - "Path"
    - "Reachable"
    - "Calculate"
---

# Nav Mesh Agent Can Reach

[Navigation](../index.md) / [Nav Mesh Agent](index.md) / **Nav Mesh Agent Can Reach**

## Description

Returns true if the Nav Mesh Agent has a complete path from where it stands to the position

## Parameters

| Name | Description |
| :--- | :---------- |
| Nav Mesh Agent | The Nav Mesh Agent component checked |
| Position | The position the path should reach |

## Code

```cs
using System;
using UnityEngine;
using UnityEngine.AI;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Title("Nav Mesh Agent Can Reach")]
    [Category("Navigation/Nav Mesh Agent/Can Reach")]
    [Description("Returns true if the Nav Mesh Agent has a complete path from where it stands to the position")]

    [Image(typeof(IconNavmeshAgent), ColorTheme.Type.Red)]
    [Keywords("Navigation", "NavMesh", "AI", "Agent", "Path", "Reachable", "Calculate")]

    [Parameter("Nav Mesh Agent", "The Nav Mesh Agent component checked")]
    [Parameter("Position", "The position the path should reach")]

    [Serializable]
    public class ConditionNavMeshAgentCanReach : Condition
    {
        [SerializeField] private GetGameObject m_NavMeshAgent = new GetGameObject(
            new GenTypeGameObject_NavMeshAgent()
        );

        [SerializeField] private GetVector3 m_Position = new GetVector3();

        [NonSerialized] private NavMeshPath m_Path;

        protected override string GetTitle(GameObject source)
        {
            string member = TextUtils.ThemeAsKeyword("Can Reach");
            return $"{this.m_NavMeshAgent} {member} {this.m_Position}";
        }

        protected override bool Run(Args args)
        {
            NavMeshAgent agent = this.m_NavMeshAgent.Get<NavMeshAgent>(args);
            if (agent == null || !agent.isActiveAndEnabled || !agent.isOnNavMesh) return false;

            this.m_Path ??= new NavMeshPath();

            if (!agent.CalculatePath(this.m_Position.Get(args), this.m_Path)) return false;
            return this.m_Path.status == NavMeshPathStatus.PathComplete;
        }
    }
}
```

