Unity 中踩到的坑

  • 如果你的Prefab上挂载了NavMeshAgent,使用”transform.posion = “来初始化prefab的位置,并在之后使用 SetDirection,会报“SetDestination” can only be called on an active agent that has been placed.” 的错,这是因为navMeshAgent无法识别位置的改变。
    解决办法:在调用SetDirection之前,用NavMeshAgent.Warp() 代替原本的 “transform.position = ”来改变位置。相关连接

你可能感兴趣的:(Unity3D)