0

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?

code11
  • 1,986
  • 5
  • 29
  • 37
aDeadPixel
  • 17
  • 4

1 Answers1

1

Perhaps use

using UnityEngine.AI;

read the latest manual https://docs.unity3d.com/ScriptReference/AI.NavMeshAgent.html

  • Sounds like it even tho it was not mentioned in any video i have seen about unity5, will check in an hour orso, if its that then will mark you as answer. – aDeadPixel Jan 08 '17 at 14:39