Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Question Best approach for baking navmesh

Discussion in 'AI & Navigation Previews' started by chris_gamedev, Jan 12, 2021.

  1. chris_gamedev

    chris_gamedev

    Joined:
    Feb 10, 2018
    Posts:
    34
    I have a scene that's built up of various mesh tiles of different types. They are all prefabs.

    I have roads, sidewalks, different types of roads and sidewalks etc.

    There seems to be two main approaches. a) I could select objects and check "Navigation Static" and then "Bake" within the Navigation window. This seems to work but I'd have to select each gameobject and assign it as static. Or b) I could use the navmesh components like NavMeshSurface and apply those to the prefabs directly, adjust settings and bake in the component and have that component propagate across all gameobjects of that prefab. That seems attractive.

    Which approach is best?

    An issue I seem to have is if I choose approach b) then my Nav Mesh Agent can no longer walk from e.g. one sidewalk to the next even though they both have the baked surface component.

    My assumption was perhaps that I'm baking the nav mesh for that component in that position and so my agent doesn't see the adjacent surface but I have tested this and when each component has a separate baked asset assigned the agent still doesn't walk to the adjacent surface.

    So essentially, two questions:

    1) What am I doing wrong with the NavMeshSurface component and, more generally,
    2) What is the best approach for this, should I just stick with assigning the navigation statically?

    Many thanks!
     
  2. DevViktoria

    DevViktoria

    Joined:
    Apr 6, 2021
    Posts:
    94
    Actually I am interested in this too. I am just learning Unity, I watched a tutorial that uses the non component approach, but now I am going through a tutorial that uses the NavMesh components approach.
    And I have no idea what is the better approach.
     
  3. Elfinnik159

    Elfinnik159

    Joined:
    Feb 24, 2013
    Posts:
    145
    As far as I know, baking static objects is a deprecated way.

    As far as I know, the recommended way is to use these components:
    https://github.com/Unity-Technologies/NavMeshComponents

    Agents cannot just move from one surface to another. To do this, you must connect surfaces using NavMeshLink (this example is in the project on GitHub).
    Another option is to have 1 NavMeshSurface, which will bake all the desired prefabs into one surface.
    The third option - you can use real-time baking (there is an example in the project on GitHub)

    However, if you need to bake the HeightMesh, it seems you should still use static bake.

    Looks like they were added in the Unity 2021.2 beta?
    https://blog.unity.com/technology/u...-,AI Navigation,-Experimental release package
     
    DevViktoria likes this.