Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
3
Question by RossMelbourne · May 30, 2014 at 07:14 PM · bakingisland

NavMesh unwanted islands

My map mesh is quite large and I used the min region area setting to remove most of the islands which formed under buildings. However a few such islands still exist even when the islands are obviously smaller than the min region area setting (which is 20,000). Either I am not understanding this setting correctly or this looks like a bug in the NavMesh feature. My enemy AIs sometimes spawn in these islands which are inside of the mesh so theyalt text cannot be seen or reached. I am using SamplePosition with a random generated position within the NavMesh. I have included a screenshot taken from underneath the NavMesh to clearly show an island and the NavMesh Bake settings.

The NavMesh is an awesome feature and I would like to learn how to avoid these islands or how to program around them.alt text

screenshot 2014-05-30 14.02.55.png (402.1 kB)
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by villevuorinen · Apr 26, 2019 at 10:50 AM

There is no answer or solution to this. It's basically careless and unprofessional programming that is rife within the Unity code.

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 idbrii · Oct 17, 2020 at 08:56 AM

Try using the free Navmesh Cleaner asset. It automatically creates NonWalkable volumes around areas that don't seem reachable. However, it doesn't take NavMeshLinks into account, but you can place a bunch of walkable indicators to allow generation on those desired islands.

To use it with NavMeshComponents, you need to make this change:

 diff --git a/Assets/NavMeshCleaner/Script/NavMeshCleaner.cs b/Assets/NavMeshCleaner/Script/NavMeshCleaner.cs
 index 2ba98ce..7d366bb 100644
 --- a/Assets/NavMeshCleaner/Script/NavMeshCleaner.cs
 +++ b/Assets/NavMeshCleaner/Script/NavMeshCleaner.cs
 @@ -1,4 +1,8 @@
 -using System.Collections.Generic;
 +// Enable define if using Unity's new NavMeshComponents:
 +// https://github.com/Unity-Technologies/NavMeshComponents
 +#define USING_NAVMESHCOMPONENTS
 +
 +using System.Collections.Generic;
  using UnityEngine;
  #if UNITY_5_3_OR_NEWER
  using UnityEngine.AI;
 @@ -76,7 +80,14 @@ public class NavMeshCleaner : MonoBehaviour
                  o.transform.localPosition = Vector3.zero;
                  o.transform.localRotation = Quaternion.identity;
                  GameObjectUtility.SetStaticEditorFlags(o, GameObjectUtility.GetStaticEditorFlags(gameObject) | StaticEditorFlags.NavigationStatic);
 +#if USING_NAVMESHCOMPONENTS
 +                var modifier = o.AddComponent<NavMeshModifier>();
 +                modifier.overrideArea = true;
 +                modifier.area = 1;
 +#else
                  GameObjectUtility.SetNavMeshArea(o, 1);
 +#endif
 +
                  m_Child.Add(o);
                  Undo.RegisterCreatedObjectUndo(o, "");
              }
 
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 Stardog · Feb 20, 2021 at 04:21 AM

Just solved this issue for myself.

 if (NavMesh.SamplePosition(hit.point, out NavMeshHit nmHit, 2f, NavMesh.AllAreas))
 {
     // Test if sampled position can be reached from NavMeshAgent's current position (is not an island)
     var testPath = new NavMeshPath();
     _navMeshAgent.CalculatePath(nmHit.position, testPath);
 
     // If reachable, use it
     if (testPath.status == NavMeshPathStatus.PathComplete)
     {
         return nmHit.position;
     }
     else
     {
         // retry
     }
 }

In OP's case, just use CalculatePath to a 'known good' part of the map after spawning an enemy. If PathComplete is false, then they are on an island, so move them somewhere else and check CalculatePath again.

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

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

23 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

Related Questions

Island collider 3 Answers

My baked Max textures are tiling when I try to apply them. 1 Answer

Realtime Shadow and baking? 0 Answers

Shadows Overlapping (Baked and Realtime) 2 Answers

Baking Indirect (bounce, radiosity) lights only 0 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