unity 自动寻路 navMeshAgent
如果给一个无法到达的目的地,怎么人物是否可以到达目的地
该回答引用NewBing
你好,这是Bing。😊
根据搜索结果,如果给一个无法到达的目的地,navMeshAgent会尝试找到最接近的可行位置,并返回PathComplete状态①。但是,如果路径还没有处理完毕,navMeshAgent.destination会返回之前设置的位置②。而navMeshAgent.remainingDistance会在路径的倒数第二个拐角处开始计算,直到无法再接近目的地为止③。
你可以使用navMeshAgent.pathStatus来检查路径是否有效或部分有效。你也可以使用navMeshAgent.CalculatePath来预先计算路径并判断是否可达。
源: 与必应的对话, 2023/3/28
(1) Getting pathComplete when destination not reachable - Unity Forum. https://forum.unity.com/threads/navmesh-getting-pathcomplete-when-destination-not-reachable.613450/ 访问时间 2023/3/28.
(2) Unity - Scripting API: AI.NavMeshAgent.destination. https://docs.unity3d.com/ScriptReference/AI.NavMeshAgent-destination.html 访问时间 2023/3/28.
(3) unity3d - Why does NavMeshAgent.remainingDistance return values of .... https://stackoverflow.com/questions/61421172/why-does-navmeshagent-remainingdistance-return-values-of-infinity-and-then-a-flo 访问时间 2023/3/28.