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
2
Question by Silverlode · May 24, 2017 at 07:41 AM · navmeshobstacleupdate-order

When is the NavMesh updated after a carving (obstacle) change

I have agents navigating using Unity's built-in NavMesh (Unity 5.6). I also have moving obstacles, which carve holes in the mesh, but only when they are stationary.

I want my agent's to re-path, after a new hole is carved into, or an existing hole removed, from the NavMesh. But if I attempt to trigger re-pathing via the obstacle gameobject broadcasting a message once it is stationary (Time to Stationary = 0), often the agents are re-pathing before the NavMesh has actually been updated.

  • So when does the NavMesh update, and how can I tell?

  • For example, is it always updated on the next FixedUpdate cycle? Always by the end of that frame?

  • Is there a way to tell if the NavMesh has un/carving changes pending, and delay path-finding until it doesn't?

  • Can my agents subsribe to an event to stay updated about NavMesh changes?

Any insight into the NavMesh update / recalculation process would be much 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

2 Replies

· Add your reply
  • Sort: 
avatar image
-1

Answer by Requiem36 · May 24, 2017 at 10:45 AM

Toggle Auto Repath on the NavmeshAgent.

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 SuperScience · Nov 04, 2019 at 02:57 AM

Hi Silverlode,

I ran into the same problem that you did. I have a solution, even if its kinda hacky. If someone else has a better solution, please let me know. However, the solution that I am about to describe does work .

Set all non-moving characters to NavMeshAgent.enabled = false and NavMeshObstacle.enabled = true. This doesn't seem to glitch.

Set moving characters to NavMeshObstacle.enabled = false and keep NavMeshAgent.enabled = false. Kick off a coroutine. Have the coroutine check the NavMesh SamplePostion once per frame (or however often you want to do it).

 NavMeshHit hit;
 if (NavMesh.SamplePosition(turn.transform.position, out hit, 1.0f, NavMesh.AllAreas)){ /*stuff */ }

If the character is ON MESH (this is important) and the Obstacle is still carving the NavMesh, the hit.distance will be > 0 . The number returned should actually be the (diameter of your obstacle + your avoidance threshold).

If the character is ON MESH and the Obstacle is no-longer carving the NavMesh, the hit.distance will become ZERO. You can then turn your NavMeshAgent back on safely.

Hope this helps!

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Static box collider and Nav Mesh Obstacle box 1 Answer

How to prevent trigger colliders from being obstacles for NavMesh? 1 Answer

[C#] Navmesh obstacles issue 0 Answers

Graphics Problem and NavMesh Obstacles 0 Answers

Trouble with Navmesh Agent and Navmesh Obstacle 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