onCollectMeshes - area tag not working

Hello,

when using RecastGraph.collectionSettings.onCollectMeshes and adding mesh as simple cube with settings for modifying area only, it always produces unwalkable tiles where navmesh is not generated for some reaason.

Is this intended behavior, or maybe a bug?

This is the code used, setting tiles with Road tag, which is 2, always produced non walkable tiles without navmesh:

   public enum PenaltyCategory
    {
        None = 0,
        Wall = 1,
        Road = 2,
        GateEntrance = 3,
        NonWalkable = -1,
        NonPlayable = 4
    }

        private Action<RecastMeshGatherer> CollectMeshes()
        {
            return gatherer =>
            {
                Debug.Log("Collecting Meshes");
                foreach (KeyValuePair<Vector2Int, PenaltyCategory> pair in penalties)
                {
                    Vector3 position = pair.Key.ToWorldPosition3D();
                    Vector3 size = Vector3.one;
                    Bounds bounds = new Bounds(position, size);

                    // Add mesh buffers to the gatherer and get the meshDataIndex
                    int meshDataIndex = gatherer.AddMeshBuffers(vertices, triangles);

                    // Transform the vertices to the world position
                    Matrix4x4 matrix = Matrix4x4.TRS(position, Quaternion.identity, Vector3.one);

                    RecastMeshGatherer.GatheredMesh gatheredMesh = new RecastMeshGatherer.GatheredMesh
                    {
                        meshDataIndex = meshDataIndex,
                        area = (int) pair.Value,
                        indexStart = 0,
                        indexEnd = triangles.Length,
                        bounds = bounds,
                        matrix = matrix,
                        solid = true, // tried both true and false, same result
                        doubleSided = false,
                        flatten = false,
                        areaIsTag = pair.Value != PenaltyCategory.NonWalkable // True for all other areas
                    };
                    
                    Debug.Log($"{pair.Key} {gatheredMesh.area} {gatheredMesh.areaIsTag} {gatheredMesh.solid}");
                    gatherer.AddMesh(gatheredMesh);
                }
            };
        }

image
image

The object itself does not have any modifiers that would prevent generation of navmesh there.

Try setting doubleSided = true. It’s possible your normals are facing the wrong way or something.

Does it generate a walkable surface if you use areaIsTag = false?

Thank you for your reply :+1:

Try setting doubleSided = true. It’s possible your normals are facing the wrong way or something.

Indeed I did not try it, but it still just blocks navmesh generation altogether.


Does it generate a walkable surface if you use areaIsTag = false?

No, no matter whether its true or false, it produces same result, unwalkable surface.
Tags or areas are not used or applied at all.

Hi

From what I can see there, it looks like a navmesh is generated on top of the object, but something along its border is unwalkable.
This could be two things:

  1. Your mesh has a slope along one of its sides, instead of a 90 degree angle. This can make the agent detect it as a slope, and not a step, and it will want to avoid walking there.
  2. The step is too high for the agent to climb. Take a look at your graph settings to see if this might be the case.

To rule out any differences between your code, and the built-in components, you can create a normal GaemObject with an appropriately configured RecastMeshObj component, and see if that generates the same result.