静态烘焙: 动态障碍物,大小要和包围盒大小一致
动态烘焙: 官方最新的 https://github.com/luoyikun/NavMeshComponents 1.可以实现烘焙信息跟随预制体
2.动态烘焙:以玩家为中心,走哪烘哪 管理器上挂载
tracked为玩家
动态烘焙中的障碍物
要挂载在mesh上
[MenuItem("HomeTool/AddNavTag")]
public static void AddNavTag()
{
GameObject obj = Selection.activeGameObject;
foreach (var item in obj.transform.GetComponentsInChildren<Renderer>())
{
if (item.GetComponent<NavMeshSourceTag>() == null)
{
item.gameObject.AddComponent<NavMeshSourceTag>();
}
}
}
显示寻路路径在scene视图中
void OnDrawGizmos()
{
var path = m_agent.path;
// color depends on status
Color c = Color.white;
switch (path.status)
{
case UnityEngine.AI.NavMeshPathStatus.PathComplete: c = Color.white; break;
case UnityEngine.AI.NavMeshPathStatus.PathInvalid: c = Color.red; break;
case UnityEngine.AI.NavMeshPathStatus.PathPartial: c = Color.yellow; break;
}
// draw the path
for (int i = 1; i < path.corners.Length; ++i)
Debug.DrawLine(path.corners[i - 1], path.corners[i], c);
}