Recast graph not working in stand alone with static batching enabled

Just curious if this is a known limitation or not, and if so, if you know of any work around. It looks like recast graphs can’t scan at runtime if you have static batching enabled. It works fine in the editor, but in stand alone you get spammed with the error:

(Filename: C:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/StandalonePlayer/Graphics.cpp Line: 1146)
Not allowed to access triangles on mesh ‘Combined Mesh (root: scene)’

and then the graph never gets built. Turning static batching off obviously fixes this, but that’s kind of a problem for obvious performance reasons. I’m assuming there must be a way to access the original unbatched mesh objects for recast purposes too, so I’m hoping this can be fixed. Let me know if you need any more info about the issue, or if I’m missing something obvious. Thanks.

-Sean

I did some digging, and I see why it doesn’t work. Combined meshes are not accessible in unity outside of the editor (no idea why reading is blocked, but it is). So, I guess the quick answer is that it won’t work as implemented.

It looks like manually combining meshes still works, but you lose the functionality that static batching provides (being able to still individually enable/disable mesh filters that are parts of the larger combined mesh), so that isn’t exactly ideal either.

One thought is to possibly add an alternative recast mode that uses colliders instead of the meshfilters. In the case of mesh colliders, they actually maintain their link to the non-combined mesh and are therefore readable, and other colliders could be manually tessellated and passed to recast.

Another possible solution I was considering is to add inactive mesh colliders to everything in the layer that doesn’t already have one, and use those to get access to the non-combined mesh during mesh collection. Anyway, I’d be curious what your thoughts on it are, or if you have any better ideas of how to get the performance benefit of batching without losing the ability to scan recast graphs at runtime.

-Sean

Ah, so that is throwing exceptions now, that’s sad. I previously created a workaround for it (ugly, but working). But apparently that won’t work now.

Rasterizing colliders is on my ToDo list.

I guess you could have dummy renderers which you activate only when scanning the graph, that would (hopefully) not affect rendering performance, but you would be able to scan the graph.