Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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
4
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 - something we've considered but obviously a simpler solution would be superior!

Any help or advice would be greatly appreciated.

Comment
Add comment
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

8 Replies

· Add your reply
  • Sort: 
avatar image
9

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
Add comment · 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
1

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

This 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 this problem submitted in the bugs forum? Having to erase all foliage, then generating navmesh, then ctrl-z ing everything 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. This is a SERIOUSLY ANNOYING limitation.

Comment
Add comment · 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 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
1

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

Fixed it by creating a small script which 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.GetComponentsInChildren<Terrain>()));
         }
 
         _terrainTrees.Clear();
         foreach (var terrain in terrains)
         {
             _terrainTrees[terrain] = terrain.terrainData.treeInstances;
             terrain.terrainData.treeInstances = new TreeInstance[0];
         }
     }
 }
Comment
Add comment · 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 at 10:32 PM 0
Share

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

avatar image
0

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, hit "edit tree" and choose this 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, hit Edit Tree and replace the tree(s) in question with this prefab. then you can put the originals back when you're done baking. still not perfect, but slightly less cumbersome in my opinion.

Comment
Add comment · 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
0

Answer by Cameon-57 · Dec 31, 2018 at 09:57 PM

I just found a similar answer, and it is based off of the ctrl + Z method. I had already finished my terrain, with large amounts of grass a trees, so naturally didn't want to erase everything. After reading the ctrl + Z idea, I realized that you could delete the trees (or grass) from the terrain brush tool, Re-Bake the navmesh, then press crtl + Z to replace the vegetation. It should not remove any of the vegetation after you press ctrl + Z, but i do advise saving the scene first in case something doesn't go right. I found this to be an faster solution.

I'm using Unity 2018.2

Comment
Add comment · 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 Cameon-57 · Dec 31, 2018 at 10:00 PM 0
Share

Also, if you want something to be detected by the Navmesh, don't delete it from the terrain brush tool.

  • 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.

Follow this Question

Answers Answers and Comments

25 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

Related Questions

Edit navmesh 2 Answers

Marking area on Terrain 1 Answer

Unity 3.5 Pathfinding with terrain and trees. 5 Answers

Reducing Lag due to Large Particle Systems and Trees 1 Answer

Can't lightmap trees! (or Character) 1 Answer


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