Search Unity

NavMesh.AddMeshData.position <-- Doesn't Exist?

Discussion in 'Navigation' started by Kardall, Apr 29, 2017.

  1. Kardall

    Kardall

    Joined:
    Mar 12, 2015
    Posts:
    2
    Edit: Unity version 5.6.0f3

    The scripting manual here: https://docs.unity3d.com/ScriptReference/AI.NavMeshData.html

    States that it is a public variable (as is rotation) but they are unavailable.

    Code (CSharp):
    1.     public Mesh CreateMesh()
    2.     {
    3.         Mesh mesh = new Mesh();
    4.         mesh.vertices = vertices;
    5.         mesh.triangles = triangles;
    6.         mesh.uv = uvs;
    7.         mesh.RecalculateNormals();
    8.         for (int i = 0; i < mesh.vertices.Length; i++)
    9.         {
    10.             // For each set of triangles which are Vector3's, we will add them to the NavMesh
    11.             TerrainType[] regions = GameObject.FindGameObjectWithTag("GameManager").GetComponent<MapGenerator>().regions;
    12.             if( vertices[i].y < regions[3].height || vertices[i].y >= regions[13].height)
    13.             {
    14.                 // Not Walkable
    15.             } else
    16.             {
    17.                 // Walkable
    18.                 NavMeshData tmp = new NavMeshData();
    19.                 tmp.position = vertices[i];    // <--- This is the part that doesn't work.
    20.                 NavMesh.AddNavMeshData(tmp, vertices[i], Quaternion.AngleAxis(90, Vector3.up));
    21.             }
    22.         }
    23.      
    24.         return mesh;
    25.     }
    This is the code I am going through. I create a mesh from PerlinNoise, and I want to take the vertices, and if it's in a certain 'height' range, then I want to add them as walkable terrain for the NavMesh. Then I will update the navmesh when it loads, and then I can have a random map with navmesh generated on the fly... however... I have hit a wall.
     
    Last edited: Apr 29, 2017
  2. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269