unity3d - 统一的 NavMeshAgent 不起作用

标签 unity3d game-engine navmesh

我正在制作一个统一的游戏,它抛出错误“无法创建代理,因为没有有效的导航网格”,我不知道问题是什么。

Setup Pic

using UnityEngine;
using System.Collections;

public class EnemyMotion : MonoBehaviour {
    public NavMeshAgent agent;
    public Rigidbody rb;
    public GameObject otwt;

    void Start () {
        rb = GetComponent<Rigidbody>();
        agent = GetComponent<NavMeshAgent>();
    }
    void Update () {
        gameObject.transform.Rotate(270, 0, 0);
        agent.SetDestination(otwt.transform.position);
    }
}

最佳答案

  • 转到窗口 -> 导航。
  • 单击烘焙选项卡。
  • 点击右下角的烘焙。

  • 这将烘焙 NavMesh,您的 NavMeshAgent 现在可以工作了。
    现在您没有导航网格,因此您的代理不知道他们可以移动/行走的位置。

    关于unity3d - 统一的 NavMeshAgent 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35210928/

    相关文章:

    iphone - 在 iPad 的 Unity 3D 游戏中指定高质量背景图像

    javascript - 弧线显示射击游戏中剩余的重新加载时间

    c++ - SDL tilemap 渲染很慢

    algorithm - 如何通过 2D 网格有效地实现光线转换?

    performance - 对于动态游戏场上拥有大量 AI 的游戏来说,哪种导航方法最高效、最灵活?

    c# - 统一: Player Jumping Issue

    c# - 如何在 CustomPropertyDrawer 中设置 SerializedProperty.propertyType

    c++ - 使用 std::vector 和类对象时出错

    unity3d - 在场景之间共享游戏对象