Terrain section Navmesh Baking

Is it possible to bake only a part of terrain (not whole very large terrain) ??

…or make mesh object from cut part of terrain

As far as I can tell, there is no built in way to do it. However, I have coded up a dirty dirty hack to get around the problem.

  1. Create a box to cover an area where you don’t want the navmesh to be baked at.
  2. Apply the RussianCreateBox script to that box (see script below)
  3. Right click on the component and select “create russian boxes”
  4. Set the navmesh layer on all generated boxes to “Navigation Static” and “not walkable”
  5. Bake your navmesh

If the spacing used by the russian box creator is less than the acceptable height for your navmesh, none should have been create inside that box.

using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;

public class RussianBoxCreator : MonoBehaviour {

  List<GameObject> newObjects = new List<GameObject>();

	// -------------------------------------------------------------------------
  [ContextMenu("Create Russian Boxes")]
  void CreateBoxes() {

    for(var i = 0; i < newObjects.Count; ++i) {
      newObjects*.transform.parent = gameObject.transform;*



// ---------------------------------------------------------------------------
void RecursiveBoxCreate(float scale) {

if (scale > 0f) {

GameObject child = Instantiate(gameObject, transform.position, transform.rotation) as GameObject;
child.transform.localScale = new Vector3(transform.localScale.x, scale, transform.localScale.z);
// You may need to tweak the value here so that it is less than your nav height setting
RecursiveBoxCreate(scale - 0.5f);


Here is my setup before:
And here is the resulting navmesh:
It’s not perfect but can probably be tweaked to be exact. Also, I named it “Russian” because of the infamous russian dolls that are nested inside one another.

It’s still in beta, but you can now use NavMeshModifierVolume from Unity’s GitHub project NavMeshComponents to mark sections of a terrain as not walkable. To do this: