Search Unity

Nav issues with map generator

Discussion in 'Scripting' started by Corva-Nocta, Jul 3, 2020.

  1. Corva-Nocta

    Corva-Nocta

    Joined:
    Feb 7, 2013
    Posts:
    801
    Hey all, I'm working on a small FPS game using Unity microgame, its been pretty fun but I'm having a small issue with the nav code in some areas. The regular code is meant to have premade levels, but I am using randomly generated levels. It seems to be affecting the nav code a lot and I'm trying to make it work. If I can't make standard unity navmesh work I might look into using the A* pathfinding code.

    I often get errors like this one:

    RuntimeNavMeshBuilder: Source mesh SM_Env_Ground_Tile_09 does not allow read access. This will work in playmode in the editor but not in player
    UnityEngine.AI.NavMeshSurface:BuildNavMesh()

    the mesh is different, but the error seems to be the same. When I go to the actual script that is wrong this the line:

    Code (csharp):
    1.  
    2. var data = NavMeshBuilder.BuildNavMeshData(GetBuildSettings(),
    3.                     sources, sourcesBounds, transform.position, transform.rotation);
    I'm not entirely sure what the problem is but if anyone has any ideas I would love to hear them
     
  2. Egad_McDad

    Egad_McDad

    Joined:
    Feb 5, 2020
    Posts:
    39
    Kinda late, but I thought I would provide the fix seeing as I got this error earlier and this question did not get answered - the problem stems from reading/writing on the
    Mesh
    being disabled. Meshes which are imported into Unity appear to have this disabled by default.

    You can re-enable it by going to the imported model and setting 'Read/Write Enabled' to true under the Import Settings in the inspector.

    To check if a
    Mesh
    is readable as runtime just check its
    .isReadable
    property