Reputation: 27
I am learning Unity on my own. I have started working on a game app I want to do. In this project I want to use the NavMeshAgent to make the "npc" locate items near it and go to grab them.
I do see the component on the gameobject but when I'm trying to reach it from a script I cannot create a variable with a type of NavMeshAgent: it's like there is no such thing!
Do I need to import something or am I missing something? I have watched the tutorials and even tried 100% same code and it doesn't recognize NavMeshAgent.
Example
If I do :
public GameObject gameObject;
Then we have created a variable called "gameObject" and is type of GameObject now if I want to create a NavMeshAgent such as :
public NavMeshAgent agent;
Then it will not recognize "NavMeshAgent" and compiler says its an error.
What should I do?
Upvotes: 0
Views: 593
Reputation: 638
Perhaps use
using UnityEngine.AI;
read the latest manual https://docs.unity3d.com/ScriptReference/AI.NavMeshAgent.html
Upvotes: 1