Okay so I undertstand how I should be doing this:
- NavMeshTriangulation.areas is an int, each element corresponds to a triangle on the Navesh, with
each int indicating the area (NavMeshTriangulation.areas[16] could be part of area 5 for example). - NavMeshTriangulation.indices is an int, in groups of 3 they correspond to the indices of the
vertices (NavMeshTriangulation.indices[0] through [5] would be { 0, 1, 2, 0, 2, 3 } for a square. - NavMeshTriangulation.vertices is a Vector3 containing the vectors of all the verts.
So to draw a ray for each vertex of an area I would:
- Loop through the area to see if the index matches my area (5), store the index in a List or something.
- Loop through the indices (using the stored area ints to make sure I’m looking at the right triangle),
store the index in another List, plus the two indexes after (to make a triangle). - Finally use the stored values in the second list to Debug.DrawRay() the vertices.
However I’ve tried doing this and it keeps coming out wrong. I can draw a ray for every vertex on the NavMesh no problem, when I try and do it for a specific area it draws the rays on points other than that.
I’m probably just messing up a really silly calculation somewhere but if I do it by hand it all checks out.
Here’s a very broken down version of my code that I made to make sure everything looked good: hatebin
Thank you for any help!