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 mihakinova · Jun 14, 2017 at 09:34 PM · navmeshprocedural

Procedurally generated NavMesh.

I have a procedurally generated scene, where, as the user moves, new tiles are generated with meshes on them.

I want to add a NavMesh to the scene that is also procedurally generated. So when each new tile is loaded, I want the NavMesh to be updated accordingly (note all of this has to be done at runtime, no way around it).

So far I have two solutions but none of them works as desired.

One thing I can do is run:

 NavMeshBuildSettings settings = NavMesh.GetSettingsByIndex(0);
 List<NavMeshBuildSource> buildSources = new List<NavMeshBuildSource>();

 NavMeshBuilder.CollectSources(null, mask, NavMeshCollectGeometry.RenderMeshes, 0, new List<NavMeshBuildMarkup>(), buildSources);
         
         
 NavMeshData data = NavMeshBuilder.BuildNavMeshData(settings, buildSources, new Bounds(Vector3.zero, Vector3.one * 10000), Vector3.zero, Quaternion.identity);
 
 NavMesh.AddNavMeshData(data);


If I run this after my terrain has been loaded I get the correct result, a single NavMesh across the entire terrain.

However, when I try to load it tile-by-tile:

 List<NavMeshBuildSource> sources = new List<NavMeshBuildSource>();
 NavMeshBuildSource s = new NavMeshBuildSource
 {
     transform = tile.transform.localToWorldMatrix,
     shape = NavMeshBuildSourceShape.Mesh,
     sourceObject = tile.MeshFilter.mesh
 };
 sources.Add(s);

 NavMeshData data = NavMeshBuilder.BuildNavMeshData(settings, sources,  new Bounds(Vector3.zero, Vector3.one * 1000), Vector3.zero, Quaternion.identity);
         

 NavMesh.AddNavMeshData(data);

I get separate NavMeshes for each tile, with a slight gap between them. Is there anything i'm missing here? Optimally I would like to add a part of the NavMesh when a tile is loaded and remove that part when it's unloaded.

Comment
Add comment · Show 2
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 Cherno · Jun 14, 2017 at 10:33 PM 0
Share

I only ever used Aron Granber's Astar Pathfinding Project for this, but anyway it's possible that you would want to take a look at $$anonymous$$esh.Combine$$anonymous$$eshes.

avatar image mihakinova Cherno · Jun 16, 2017 at 01:00 AM 0
Share

This might just work, however i feel that it's somewhat inefficient. But I do only have 2 triangles per tile, and ~ 50 tiles loaded at the same time, so recalculating everything might not be a bad idea... i'll try it!

0 Replies

· Add your reply
  • Sort: 

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

72 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

Related Questions

Proceduraly Generated Levels vs NPC Navigation 1 Answer

Procedural NavMesh Instantiating 0 Answers

NavMesh with geometry mesh generated at runtime 1 Answer

Dynamic NavMesh Creation at Runtime? 1 Answer

Procedural pathfinding 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