前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Assets/FollowDestination.cs(6,13): error CS0246: The type or namespace name `NavMeshAgent' could not

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

作者头像
Zoctopus
发布2018-06-04 10:26:19
8740
发布2018-06-04 10:26:19
举报
文章被收录于专栏:章鱼的慢慢技术路

问题的出现与描述

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

代码语言:javascript
复制
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

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018-04-04 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 问题的出现与描述
  • 解决方案
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档