• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by CynicalCode · Dec 17, 2012 at 01:11 AM · terrainpathfindingnavigationtreesbaking

Can I ignore trees when baking NavMesh on Terrain?

I understand that in Unity 3.5, the NavMesh system was updated to bake the mesh around trees. However, it seems as though there is no option to ignore them!

For the purposes of my current project, I actually want to ignore trees for the purposes of hard navigation via NavMeshAgent.

I have tried the following:

  • Uncheck 'Create Tree Colliders' on Terrain Collider component and re-bake navemesh

  • Uncheck 'Draw Trees' on Terrain Component Settings tab and re-bake navmesh

Ultimately I realise that I could bake the navmesh before applying the trees, but unfortunately that is a time-consuming process since our artist has already created our terrain.

Another option is to use custom navigation - somet$$anonymous$$ng we've considered but obviously a simpler solution would be superior!

Any help or advice would be greatly appreciated.

Comment
JadsonAlmeida
Leon123442
shivamsingh0797
unknownsk

People who like this

4 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

9 Replies

· Add your reply
  • Sort: 
avatar image

Answer by pipiroo6 · Apr 13, 2014 at 02:52 PM

I had the same problem, my only solution was delete all the trees with the big Brush, Bake the NavMesh, and then undo with Ctrl + z.

In that way you can keep your artist modifications and have the proper nav mesh.

It's far from be elegant, but Im running out of ideas.

Comment
Dubious-Drewski
JadsonAlmeida
naderlabbad309
R33F
Propagant
Brainversation01
GamesOfArcadia
unknownsk
fuadshahmuradov

People who like this

9 Show 8 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JadsonAlmeida · May 19, 2017 at 07:29 PM 0
Share

And we are here, 2017, and stay the same. Thank you for workaround.

avatar image FPV JadsonAlmeida · Jan 24, 2018 at 05:44 PM 0
Share

It's 2018, and it's still not fixed.

avatar image tormentoarmagedoom FPV · Sep 30, 2019 at 06:26 PM 0
Share

Its 2019, and now its solved

Show more comments
Show more comments
avatar image AzizStark JadsonAlmeida · Jan 13, 2021 at 09:34 AM 0
Share

It's 2021 still not fixed.

avatar image unknownsk · Oct 28, 2021 at 07:51 PM 0
Share

thanks! you saved me! :) you are so creative, this is nice trick

avatar image

Answer by Dubious-Drewski · May 12, 2014 at 02:00 PM

T$$anonymous$$s is a glaring oversight and a big pain in my butt. Why does the navmesh generator completely ignore the "create tree collider" option? Now my AI carefully avoids stepping on any tiny plants or grass even though none of them have a collider attached. It's ridiculous.

Is t$$anonymous$$s problem submitted in the bugs forum? Having to erase all foliage, then generating navmesh, then ctrl-z ing everyt$$anonymous$$ng back is cumbersome. And what if you need to have walkable shrubs but you need trees to block paths? It can't be done unless you add shrubs at the very last step of level creation. T$$anonymous$$s is a SERIOUSLY ANNOYING limitation.

Comment
AldeRoberge

People who like this

1 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AldeRoberge · Jan 22, 2022 at 10:33 PM 0
Share

Almost 10 years later, this is still a very real problem. How did they never fix this?

avatar image

Answer by unity-marcus · Jul 11, 2020 at 02:55 PM

Fixed it by creating a small script w$$anonymous$$ch first erases all trees and then restores them:

 using System.Collections.Generic;
 using System.Linq;
 using UnityEditor;
 using UnityEditor.AI;
 using UnityEngine;
 using UnityEngine.SceneManagement;
 
 public class TerrainNavMeshBaker 
 {
     private static Dictionary<Terrain, TreeInstance[]> _terrainTrees = new Dictionary<Terrain, TreeInstance[]>();
 
     [MenuItem("Tools/Bake NavMesh")]
     public static void BakeNavMesh()
     {
         try
         {
             RemoveTrees();
             NavMeshBuilder.BuildNavMesh();
         }
         finally
         {
             RestoreTrees();
         }
     }
 
     private static void RestoreTrees()
     {
         foreach (var terrain in _terrainTrees)
         {
             terrain.Key.terrainData.treeInstances = terrain.Value;
         }
     }
 
     private static void RemoveTrees()
     {
         var terrains = new List<Terrain>();
 
         for (int i = 0; i < SceneManager.sceneCount; i++)
         {
             var scene = SceneManager.GetSceneAt(i);
 
             if (!scene.isLoaded)
                 continue;
 
             terrains.AddRange(scene.GetRootGameObjects().SelectMany(x => x.GetComponentsInC$$anonymous$$ldren<Terrain>()));
         }
 
         _terrainTrees.Clear();
         foreach (var terrain in terrains)
         {
             _terrainTrees[terrain] = terrain.terrainData.treeInstances;
             terrain.terrainData.treeInstances = new TreeInstance[0];
         }
     }
 }
Comment
benthroop

People who like this

1 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AldeRoberge · Jan 22, 2022 at 10:32 PM 0
Share

'TerrainNavMeshBaker' is missing the class attribute 'ExtensionOfNativeClass'!

avatar image

Answer by roy_yu · Feb 18, 2019 at 07:41 AM

You may can open "navigation" window and set the tree not walkable. Clear old bake, and select " Bake" option, then bake. https://www.youtube.com/watch?v=S2mK6KFdv0I∈dex=2&list=PLPV2KyIb3jR4KLGCCAciWQ5qHudKtYeP7

Comment
spilat12

People who like this

-1 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Lev_King · Mar 18, 2019 at 09:56 AM 0
Share

Not if your trees are terrain trees

avatar image

Answer by CampbellFletcher · Dec 05, 2017 at 08:53 PM

pipiroo6's workaround has inspired me, and i have one that some might prefer: make a prefab of an empty game object, and when you need to bake, $$anonymous$$t "edit tree" and choose t$$anonymous$$s prefab for all trees you want to ignore. Still not perfect, but less cumbersome for me at least.,pipiroo6's workaround has inspired me, and i have what might be a better one for some people: make a prefab of an empty game object, and when you need to bake, $$anonymous$$t Edit Tree and replace the tree(s) in question with t$$anonymous$$s prefab. then you can put the originals back when you're done baking. still not perfect, but slightly less cumbersome in my opinion.

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

26 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity 3.5 Pathfinding with terrain and trees. 5 Answers

Edit navmesh 2 Answers

Marking area on Terrain 1 Answer

Terrain trees not casting shadow 1 Answer

Removing colliders from terrain trees 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges