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
0
Question by gcarlso · May 02, 2021 at 12:22 AM · nav mesh

How to update nav mesh without lagging game?

Hi, I'm currently working on a scene where I create a new maze-like level each round, with randomly generated walls, and enemies spawn around the edges of the level and move toward the center. In order to make the enemies path properly, they each have a Nav Mesh Agent and the wall prefabs have Nav Mesh Surfaces. Currently, I call NavMeshBuilder.BuildNavMesh(); after putting in the new walls, and this causes the enemies to properly pathfind around them. There's only one problem: rebuilding the nav mesh like this causes the game to freeze for several seconds when it's called.

How can I generate new terrain like this so that the enemies will path around it properly without freezing? Can I rebake the mesh asynchronously? One thing I tried was giving the wall prefabs Nav Mesh Obstacles, which removed the need to rebake the mesh, and the enemies do avoid the walls, but the enemies no longer take the most efficient route to the goal and tend to wander a bit. What's the best solution here? Thanks

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by gigos22 · May 02, 2021 at 05:02 AM

As far as I know, might be wrong, BuildNavMesh() cannot be natively async unless you make something up yourself, let's say sending it to a Task or a Thread. Either way, it is not recommended to my knowledge. But just like when working on Unity and baking the navmesh, you can't do anything while it is baking..

For this, the best solution is to prompt some kind of UI that says that the level is loading, thus it doesn't looks like it's freezing, it looks like it's the game being it's thing..


Secondly, if you see that it works better with walls being NavMeshSurfaces and not Obstacles - you should keep it that way.

For a game, it doesn't matter to it how it works.

Comment
Add comment · Show 2 · 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 gcarlso · May 02, 2021 at 07:25 AM 0
Share

Thanks for the tips. I had considered adding a "loading" between levels, but one of our core design plans was to make the level transition seamless, since for a short time both levels will be active at once (the defense objective falls through the floor then the player must do so soon after in order to keep defending). Since each level is flat, would it possible to optimize the mesh enough to speed up the bake to the point where it's not noticeable?

avatar image gigos22 gcarlso · May 02, 2021 at 02:01 PM 0
Share

I've never thought about trying to achieve that.. Interesting.

Maybe try to tweak the voxel size of the bake..

If it is split into less voxels maybe it would take less time to bake.

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

117 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 avatar image

Related Questions

Disable NavMeshAgents Colliding, but not Everything 0 Answers

NavMeshAgent cannot walk around the obstacles 0 Answers

How do I make a character step up or down with a NavMesh? 0 Answers

How would I simulate a rectangular Nav Mesh Agent? 0 Answers

NavMesh Obstacle Problem 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