NavMesAgent script issue

So, I am unsure if this is cause might be outdated tutorial I’m using the Survival Shooter making a enemy, It shows I should use NaveMeshAgent but when i input it for NavMeshAgent nav; It wont highlight like it would with the Transform player; So I’m unsure what I am doing wrong. It spits out: “The type or namespace name NavMeshAgent could not be found(are you missing a using directive or an assembly reference?)” When I go to quick fix guide it mentions using UnityEngine.AI but I am unfamiliar with that and unsure if that would be the solution to my problem.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DragonMove : MonoBehaviour {
    Transform player;
    NavMeshAgent nav;


    void Awake()
    {
        // Set up the references.
        player = GameObject.FindGameObjectWithTag("Player").transform;
        nav = GetComponent<NavMeshAgent>();
    }


    void Update()
    {
            nav.SetDestination(player.position);
    }
}

I just ran through this and had the same problem. I believe it was as simple as adding this to top of script.

using UnityEngine.AI;

Or you can complete the line of code for the nav variable with this and skip that “using” line:

nav = GetComponent<UnityEngine.AI.NavMeshAgent>();

1 Like

Yes that has seems to made it to work, for creature to follow. I guess it was simple as that.