read

3 Actor AI

  • Find source project Tutorial_3_AI in Shooter

Add AI

Add AI to enemies, mainly path finding. Bake navigation first.

Add NavMeshAgent to AI models.

Use script to give them destination.

To avoid polluting complete game script, all script class should be put inside namespace Tutorial.

    public Transform destPoint;                             
    private NavMeshAgent nav;

    void Awake()
    {
        nav = GetComponent<UnityEngine.AI.NavMeshAgent>();  
        if (!nav)
            return;
        Init();
    }
    public void Init()
    {
        nav.SetDestination(destPoint.position);     // set nav destination
    }

Next turoial please click Enemy patrols.

More details, please visit the project here

Blog Logo

Honglei Han 韩红雷


Published

Image

Honglei Han 韩红雷的主页

Honglei Han from CUC 中国传媒大学 游戏设计 韩红雷 科研信息 所带课程 个人介绍 开源项目 创作的部分古体诗 Unity 3D 游戏引擎 Game Engine 游戏开发 计算机图形学 虚拟现实 Virtual Reality 程序设计 Programming

Back to Overview