Search Unity

NavMeshAgent Variable

Discussion in 'Navigation' started by tya280296, Mar 27, 2022.

  1. tya280296

    tya280296

    Joined:
    Dec 28, 2020
    Posts:
    7
    I, have a problem when i write a nav mesh agent variable, but it say: Type or namespace name 'NavMeshAgent' not found (are you missing a using directive or an assembly reference?) [Assembly-CSharp]


    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEditor.AI;
    public class AnimAIPlayer : MonoBehaviour
    {

    public NavMeshAgent navMeshAgent;
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }


    }
     
  2. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    You need to add a using statement for the namespace it's in, which is probably UnityEngine.AI. But any modern IDE would tell you that automatically without a trip to the forums. The documentation tells you, too (https://docs.unity3d.com/ScriptReference/AI.NavMeshAgent.html).

    I strongly suggest that you learn C# before delving into pathfinding or any kind of AI or other unity development.