Unity - “SetDestination” can only be called on an active agent that has been placed on a NavMesh. UnityEngine.NavMeshAgent:SetDestination(Vector3)

匿名 (未验证) 提交于 2019-12-03 00:56:02

问题:

I'm using Unity5 right now. I got this error when try to setDestination.

"SetDestination" can only be called on an active agent that has been placed on a NavMesh. UnityEngine.NavMeshAgent:SetDestination(Vector3) CompleteProject.EnemyMovement:Update() (at Assets/_CompletedAssets/Scripts/Enemy/EnemyMovement.cs:30)

My code.

Please advice. Thank you.

Reference: https://github.com/datomnurdin/SurvivalShooter

回答1:

You need to add a Navmesh to your scene before you can use NavMeshAgent or anything else related to Navigation.

Here's some videos by Unity about Navigation



回答2:

1.Make sure that your thirdPersonController is above the ground.

2.Go to Window->Navigation->Bake and click bake.The blue area is where the thirdperson can reach in the ground.



回答3:

  1. Your floor (plane or quad) must be static.
  2. Add NavmeshAgent component your player or your enemy.

You can find static checkbox on inspector panel



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!