简体   繁体   中英

Baking Unity NavMeshSurface from NavMeshComponents on C# Generated Mesh

Problem:
I'm having problems baking a C# generated mesh using the NavMeshSurface script provided in NavMeshComponents .

If I bake the NavMeshSurface on the "WalkableMesh" GameObject the baking is over quickly and nothing is walkable. The NavMeshSurface does not turn blue to indicate it is navigable. 可步行的meshunbaked

Setup/Installation:
Here is a complete zip of the assets if you would like to see the behavior I describe below. Copy these into your project root (I'm using Unity 2019.3) and you'll be half way there.

Below are the settings for my agent. You will have to set your agent to these settings in the Navigation window. To modify these settings, in the toolbar select Window->AI->Navigation
在此处输入图像描述

These are the settings you'll have to set on the PLANE NavMeshSurface. This allows the NavMesh geometry to be detailed enough to bake single tiles at the 32x16px size. 在此处输入图像描述

Further Information:
I'm creating the meshes I'm trying to bake by iterating over a TileMap. This allows me to have separate areas with completely separate meshes for the differing pathing costs. As I said above baking does not work on these meshes directly.

I can bake the NavMesh INDIRECTLY by taking a separate plane and baking that plane ANYWHERE in the scene. Baking will bake both the plane and the NavMeshSurface on the "WalkableSurface" GameObject. The area assigned to the generated NavMesh is determined by the plane GameObject's NavMeshSurface area settings.

1) Why does the WalkableMesh object not bake without this plane?
2) Why does the plane bake the WalkableMesh?

You can see the square plane baking the WalkableSurface below. 可步行网布带平面 在此处输入图像描述

The NavMeshSurface I'm adding in code also reports the Namespace could not be found but it is added nonetheless.
Error CS0246 The type or namespace name 'NavMeshSurface' could not be found (are you missing a using directive or an assembly reference?)

Basically all my problems went away when I decided to move my NavMesh to the XZ plane.

This library SHOULD WORK with the XY plane but it clearly doesn't work properly. It seems like it's ALMOST there but it just isn't.

The process for baking the meshes is now to simply make the meshes in turn, setting the area type, and then baking from the Navigation window.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM