Search Unity

  1. Curious about what's going to be in 2020.1? Have a look at the 2020.1 beta blog post.
    Dismiss Notice

Cannot update NavMesh when Batching Static is enabled

Discussion in 'AI & Navigation Previews' started by Polygon_Soup, Dec 16, 2017.

  1. Polygon_Soup

    Polygon_Soup

    Joined:
    Nov 5, 2017
    Posts:
    7
    I've recently started learning how Unity's pathfinding works under the hood, by using the NavMesh Components From Github as an aid.

    However, I've been experiencing a problem when static objects gets batched. Here is what my scene looks like:



    Both, the "Ground" and "Building" objects have been declared as static objects. I use the NavMeshSurface.cs component to build the NavMesh. I then call the UpdateNavMesh() method from the NavMeshSurface.cs component in my custom component. This is what my code looks like:
    Code (CSharp):
    1. NavMeshSurface updateNavMesh;
    2.  
    3. void Start ()
    4. {
    5.     updateNavMesh = GetComponent<NavMeshSurface>();
    6.  
    7.     StartCoroutine(NavMeshUpdateInterval());
    8. }
    9.  
    10. IEnumerator NavMeshUpdateInterval()
    11. {
    12.     while (true)
    13.     {
    14.         yield return updateNavMesh.UpdateNavMesh(updateNavMesh.navMeshData);
    15.     }
    16. }
    When I run my custom script, my scene crashes with the following error:
    I then disable Batching Static on all static objects and the scene runs perfectly fine without crashing. Is this perhaps a bug?
     

    Attached Files:

  2. xxhaissamxx

    xxhaissamxx

    Joined:
    Jan 12, 2015
    Posts:
    130
    i have same issue did u found any solutions ??
     
  3. jmguillemette

    jmguillemette

    Joined:
    Mar 4, 2015
    Posts:
    22
    The issue you have both run into is due to an overlap in how the static variable has historically been used.

    If your object has a navmesh on it and it flagged as static .. then its assumed to be part of a "global" navmesh that will be generated. However the new NavMeshComponent system is "componentized" and thus dynamic,

    The error is basically saying you can mix the baked global mesh with the componentized one (and your object is basically flag to be both)

    Static batch also uses the same static flag. However if your object has a navmesh on it.. its likely not going to be batched.
     
  4. Polygon_Soup

    Polygon_Soup

    Joined:
    Nov 5, 2017
    Posts:
    7
    Yes. All I did was change 'Use Geometry' property from NavMeshSurface component to 'Physics Colliders'. Also ensure that all your obstacles have colliders attached to them
     
    xxhaissamxx likes this.
  5. Polygon_Soup

    Polygon_Soup

    Joined:
    Nov 5, 2017
    Posts:
    7
    Yeah, I thought it was some kind of bug. But when I opened up a report, the Unity staff told me all about it.
     
unityunity