Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by Riki9811 · Sep 09, 2019 at 03:31 PM · navmeshnavmeshagentruntimebakingsurface

When baking a Navmesh Surface at runtime 'Include Layers' property gets ignored

I am using the Unity NavMesh Components to bake a randomly generated map in my game.

I use the NavMesh Surface component to be able to bake during runtime. I have my player gameObject standing on top of the map ant to make it so that the area around it does not get cut out I set the player (and all it's child objects) on a separate layer called "Player". Then I set the Surface 'Include Layer' property to every layer except the "Player" one. When I bake in the scene (not during runtime) the player gets ignored and the map around it is set as walkable (highlighted in blue).

The problem is that without changing anything (no parameters, no layers, no properties…) when I bake during runtime the player is counted as an obstacle and the map around him is cut out of the NavMesh.


I bake the surface at runtime like this:

  using UnityEngine;
  using UnityEngine.AI;
  
  public class NavigationManager : MonoBehaviour
  {
      public NavMeshSurface surface;
  
      public void Bake()
      {
              surface.BuildNavMesh();
      }
  }

I think I could "fix" this issue by moving the player up in the sky before baking and then bringing it back to its position, but this is just a work around. Am I doing something wrong, or is it a bug of the NavMesh Components?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by jkeogh1413 · Dec 21, 2019 at 12:02 AM

Any luck here? I'm having the same issue.

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 jihadkhawaja · Dec 21, 2019 at 12:32 AM

First of all please check if these are set correctly:

  1. Navmesh agent component collider is placed correctly on player model.

  2. Be sure you applied the Navmesh included layers on the level gameobject.

  3. Check for any ignore from build Navmesh modifier component on any of the level gameobjects.

  4. Be sure that the Navmesh is set to calculate Mesh instead of physical collider incase u didn’t add colliders to the map

  5. Try to manually bake your Navmesh on runtime to find the issue.

Lastly provide screenshots for your Navmesh components in case this didn’t help.

Comment
Add comment · Show 4 · 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 jkeogh1413 · Dec 23, 2019 at 05:36 AM 0
Share

Thanks @khawajajihad

Here are the supporting images https://imgur.com/a/ciORmS2


This is immediately after changing obstacle layouts and rebuilding the navmesh during runtime. You can see that I'm ignoring a few layers. I included an image of the Toe as an example of a collider on the Player object that is touching the surface that the navmesh is being built on. All GameObjects on the Player that include a collider are tagged with the $$anonymous$$yPlayer tag. There are no other colliders occupying this space during the rebuild of the navmesh.


You can see that the obstacles that I intend to build the navmesh around are properly included in the build and the navmesh is not generated in those areas. I am using the Physics Colliders geometry setting, which I believe is appropriate for my setup. I do not have a Nav$$anonymous$$eshAgent on the Player GameObject, but I don't think that should impact the navmesh that is generated.


Let me know if you have any ideas! Thanks

avatar image jihadkhawaja · Dec 23, 2019 at 08:03 PM 0
Share

@$$anonymous$$eogh1413 can u please include all layers and then try to generate a map and bake it ay runtime to see if the error persists , if it was fixed that means you need to make a script which set the layer name of each gameobject instantiated on awake and the bake navmesh. However if the issue still persists then it might be that the box colliders (if ur not using mesh col) are not in the correct on of the generated map gameobjects. Hope this helps otherwise we need to do more debugging.

Were trying to annihilate possibilities here.

avatar image jkeogh1413 jihadkhawaja · Dec 24, 2019 at 08:39 PM 0
Share

Got it!

So, when I set layers back to Everything, I noticed that the hole got bigger. That made me wonder which colliders were being included in the build. So, in Nav$$anonymous$$eshSurface after collecting sources (https://github.com/Unity-Technologies/Nav$$anonymous$$eshComponents/blob/master/Assets/Nav$$anonymous$$eshComponents/Scripts/Nav$$anonymous$$eshSurface.cs#L341) I printed out each source collected. This led me to find a rogue collider on a non-player object (the VR SD$$anonymous$$ head, to be exact) that was not in an ignored layer. Adding this rogue collider to an ignore layer fixed my issue.

I noticed also that even if an item is not colliding with the ground, it'll be included. Is it possible to ignore colliders that are not on the floor surface itself?

Thanks for the help!

avatar image jihadkhawaja jkeogh1413 · Dec 24, 2019 at 09:17 PM 0
Share

Glad to help and see ur issue being fixed

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

116 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 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 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 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 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

How to know if a navmesh is baked at runtime? 0 Answers

Procedural NavMesh Instantiating 0 Answers

Nav Mesh only rebake changed areas? 0 Answers

Limit area nav mesh is baked on terrain 0 Answers

Updating NavMesh settings during runtime. 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