unity报错The type or namespace name `NavMeshAgent' could not be found.

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了unity报错The type or namespace name `NavMeshAgent' could not be found.相关的知识,希望对你有一定的参考价值。

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

public class monsterctrl : MonoBehaviour

private Transform monsterTR;
private Transform playerTR;
private NavMeshAgent nvAgent;

// Use this for initialization
void Start ()
monsterTR = GetComponent<Transform>();
playerTR = GameObject.FingWithTag("Player").GetComponent<Transform>();
nvAgent = GetComponent<NavMeshAgent>();
nvAgent.destination=playerTR.prostion;


// Update is called once per frame



以上为脚本代码,
以下为报错信息
error CS0246: The type or namespace name `NavMeshAgent' could not be found. Are you missing `UnityEngine.AI' using directive?
弄了好久没发现问题在哪,这是一个自动寻路的脚本
问题已解决,是api更新了,引用组件要加上UnityEngine.AI.NavMeshAgent

参考技术A 这个需要看你的漫游的方法。
若是使用navMeshAgent导航的话,可以使用hasPath()方法来判断是否可以到达。
如果使用第一人称控制器的话,可以用目标点的高度进行基本的判断。
参考技术B 开头加上Using UnityEngine.AI试试

Unity打开项目报错提示Could not establish a connection with the Unity Package Manager local server process

报错

我用的2018.3.0的unity版本,以前打开项目都是好好的,刚刚去打开项目,结果出现如下提示:

Could not establish a connection with the Unity Package Manager local server process.This is most likely due to a proxy or firewall configuration. Make sure the process[D:/Program
Files/Unity/Editor/Data/Resources/PackageManager/Server/UnityPackageManager.exe]is reachable via HT TP on the IP address 127.0.0.1.

解决办法

先把vpn关了,又在Windows设置->网络和internet->代理->自动设置代理->自动检测设置打开。

以上是关于unity报错The type or namespace name `NavMeshAgent' could not be found.的主要内容,如果未能解决你的问题,请参考以下文章

报错The "chunk" argument must be one of type string or Buffer. Received type object

Unity3d 2021版本播放视频组件VideoPlayer报错The type name ‘VideoPlayer‘ could not be found in the namespace...

node.js使用报错“The chunk argument must be of type string or an instance of Buffer or Uint8Array“

Assets/FollowDestination.cs(6,13): error CS0246: The type or namespace name `NavMeshAgent' could

记一次使用pm2运行node+ts项目,ts-node报错问题To load an ES module, set “type“: “module“ in the package.json or use

Unity报错 GameObject is already being activated or deactivated