Including invisible objects into navmesh baking

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?

—EDIT—

Ugh… googled a bit and found couple of other quesitons mentioning this “feature”:
http://forum.unity3d.com/threads/script-baking-navmeshes-for-hidden-objects.128345/
http://answers.unity3d.com/questions/421030/how-to-generate-a-navmesh-only-with-colliders.html

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.

Guess I’ll need to write another script.

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

http://luigigarcia.byethost7.com/2015/08/16/navmesh-helper-baking-scene-based-on-colliders/

You can add a script to destroy that when the game run

Dependin on what you need, in start methode, you can call “Destroy(gameObject)” or “Destroy(GetComponent())”

That will save some performance for you if you don’t need the component when the game runs

I have a lot of hidden boxes that they auto destroy themselves when the game runs

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.

1 Like

If you enable the mesh but put a completely transparent texture that should do the trick

there should be an option for that, this is unacceptable