When baking navmesh, how can I include invisible objects into process?
If I make a cube, set it to “navigation static”, disable “mesh renderer” component and attempt to bake navmesh, the cube is ignored, unless I re-enable “mesh renderer” component.
How can I change that behavior? I’d like to keep some objects hidden AND include them into navmesh baking.
Make sure that you don’t disable the game object, but only the mesh renderer. Like that, the game object including the BoxCollider will still be active and considered for the NavMesh calculation.
Here is object configuration (see panel on the right). Object enabled, mesh renderer disabled, collider enabled. The object is ignored by mesh baking system. What am I missing?
I COULD put alpha-test shader on it and throw 1x1 pixel texture with 0 alpha, but it is kinda silly (because graphical subsystem would still attempt to “draw” it). Is there a better way to do it?
It looks like navmesh ignores anything that does not have mesh renderer, and the only way to fix it is to temporarily enable renderers before navmesh baking.
I’ve solved the problem by making a script that temporarily makes invisible colliders visible and then bakes navmesh. There doesn’t seem to be any other way to do it.
Little too late, but I have worked in an editor that might help.
…The NavMesh helper is an editor script that will prepare your scene for the NavMesh baking process. As we know, the Unity’s bake process is based on renderers. So the helper generates temporary objects with renderers created from the original object’s collider…
Either prebake the navmesh and destroy all the objects. I guess you could do this in unity. Pretty much what @Shibli suggested.
Have you tried going to the meshrenderer and setting cast shadows to shadows only? If not you could also put all the objects on their own layer and make no camera render it, or give them all carving navmeshobstacles. But the first solution is more efficient.
Worst case scenario, change pathfinding solutions. #A*MasterRace
If you don’t need to bake anyway, you may use adding a “Nav Mesh Obstacle” component to your object. This component also adds a hole to walkable area around the object when “Carve” is checked.