RecastMeshObj Layers


I’m using multiple recast graphs in a single level for different agent types. Per pathfinding graph I can configure a LayerMask so it filters out colliders, this works as expected. However, when I use the RecastMeshObj the GameObject always gets added to all pathfinding graphs, regardless of the GameObjects LayerMask.
I did a bit of digging and it looks like the RecastMeshGatherer.CollectRecastMeshObjs() does not filter on LayerMask. It looks like the RecastMeshGatherer already has support for LayerMasks and it does filter in eg. CollectColliderMeshes().

Could this same filtering also be added to CollectRecastMeshObjs?

Thanks in advance!


This is intentional. A RecastMeshObj always indicates that the object should be included in the scan.

I see, in this case how could I make colliders Unwalkable?

If you want to make colliders unwalkable (and included in the scan) then use a RecastMeshObj component and set its mode to Unwalkable Surface.

Ah, but you just said if I add RecastMeshObj it will get added to both graphs, which is not what I want.

If I cannot use RecastMeshObj, what should I use to make it unwalkable?
If I do have to use RecastMeshObj to make it unwalkable, how do I make them end up in the correct graph?

Small update; if anyone runs into this problem in the future this is how I solved it.
In RecastMeshGatherer.cs line 176 and RecastMeshGathererBurst.cs line 427 (v4.3.60) add the following:

if(((1 << coll.gameObject.layer) & mask) == 0)

With this the RecastMeshObj will respect the LayerMask set in the nav graph.

1 Like

Thank you naimo, very helpful.
An option for RecatMeshGatherer to ignore or respect layers when gathering RecastMeshObj would be really handy.


In the next beta version, there will be an option for this :slight_smile:

1 Like