Assets/FollowDestination.cs(6,13): error CS0246: The type or namespace name `NavMeshAgent' could not be found. Are you missing `UnityEngine.AI' using directive?的解决方案

问题的出现与描述

在Unity中创建一个NPC,使它一直跟踪一个目标Destination,C#脚本代码如下,错误信息描述如下

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

public class FollowDestination : MonoBehaviour {
    private NavMeshAgent ThisAgent = null;
    public Transform Destination = null;

    void Awake()
    {
        ThisAgent = GetComponent<NavMeshAgent>();
    }
    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {
        ThisAgent.SetDestination(Destination.position);
    }
}

解决方案

根据提示信息我知道原因是 “缺失的是引用UnityEngine.AI命名空间的指令 ”,所以我们要在FollowDestination.cs 中加上 using UnityEngine.AI

Assets/FollowDestination.cs(6,13): error CS0246: The type or namespace name `NavMeshAgent' could not be found. Are you missing `UnityEngine.AI' using directive?的解决方案

原文地址:https://www.cnblogs.com/OctoptusLian/p/8718332.html

时间: 2024-11-10 11:22:57

Assets/FollowDestination.cs(6,13): error CS0246: The type or namespace name `NavMeshAgent' could not be found. Are you missing `UnityEngine.AI' using directive?的解决方案的相关文章

[virsh] error: unknown OS type hvm解决办法

今天在linux服务器上编译安装升级了下qemu,升级命令如下: [email protected]:/opt/qemu-2.0.0# ./configure --prefix=/usr/local/ --target-list=x86_64-softmmu [email protected]:/opt/qemu-2.0.0# make [email protected]:/opt/qemu-2.0.0# make install 顺利编译安装后,去define了一个虚拟机,结果报了如下错误:

scala 2.11报错error: not found: type Application

FROM: http://j-q-j.org/scala/scala-2-11-application-error.html 这两天学习scala,官网下载的最新版本2.11,书用的是<Programming in scala>,看到类和对象,这一章最后一段代码 1 2 3 4 5 import ChecksumAccumulator.calculate object FallWinterSpringSummer extends Application {   for (season <

C++ Error:C2011: &#39;struct&#39; type redefinition

C++ Error:C2011: 'struct' type redefinition 在c语言中,对同一个变量或者函数进行多次声明是不会报错的.所以如果h文件里只是进行了声明工作,即使不使用# ifndef宏定义,一个c文件多次包含同一个h文件也不会报错. 但是在c++语言中,#ifndef的作用域只是在单个文件中.所以如果h文件里定义了全局变量,即使采用#ifndef宏定义,一个c文件包含同一个h文件多次还是会出现全局变量重定义的错误. 使用#ifndef可以避免下面这种错误:如果在h文件中

Solve Error: &#39;has incomplete type&#39;, foward declaration of &#39;class x&#39;

在C++的OOB编程中,有时候我们会遇到这样的错误Error: 'has incomplete type',forward declaration of 'class x',那么是什么原因引起的这个问题呢,我们首先来看下面这段代码: // Error: field '_a' has incomplete type 'A' // forward declaration of 'class A' class A; class B { public: B(A a): _a(a) {} private:

..\SYSTEM\usart\usart.c(48): error: #260-D: explicit type is missing (&quot;int&quot; assumed)

..\SYSTEM\usart\usart.c(48): error:  #260-D: explicit type is missing ("int" assumed) SYSTEM\usart\usart.c(48) 第48行报错,如图 添加 void  不报错,编译通过 原文地址:https://www.cnblogs.com/ys77/p/11539907.html

intelliJ IDEA 13 error: please select Android SDK

I encountered this error after installing Intellij IDEA Ultimate 14.1 and opening an existing Android project I had created using Android Studio. It turns out I just had to add the Android SDK to my list of SDKs and fix the project/module SDK setting

Java基础(13) - Error与Exception

Error(错误)是系统中的错误,程序员是不能改变的和处理的,是在程序编译时出现的错误,只能通过修改程序才能修正.一般是指与虚拟机相关的问题,如系统崩溃,虚拟机错误,内存空间不足,方法调用栈溢等.对于这类错误的导致的应用程序中断,仅靠程序本身无法恢复和和预防,遇到这样的错误,建议让程序终止. Exception异常 表示程序可以处理的异常,可以捕获且可能恢复.遇到这类异常,应该尽可能处理异常,使程序恢复运行,而不应该随意终止异常. Exception又分为两类 CheckedException:

SQL Server error &quot;Xml data type is not supported in distributed queries&quot; and workaround for it

Recently while working with data migration,got an error while running a following query where Server2 has beed added as linked server. SELECT * FROM Server1.Database1.dbo.Table1 WHERE Column1 NOT IN (SELECT Column1 FROM Server2.Database2.dbo.Table1)

ERROR:The type javax.servlet.http.HttpServletRequest cannot be resolved.

MyEclipse中附加工程出现如下错误:The type javax.servlet.http.HttpServletRequest cannot be resolved.  解决方法如下: (1)右键工程找到build path项 (2)找到Add Libraries (3)点击myEclipse Libraries,Next (4)添加JavaEE 5