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 /
  • Help Room /
avatar image
0
Question by josh_s_dev · Feb 15, 2016 at 04:04 AM · navmeshagentpathdestination

What would cause a NavMeshAgent's path to be cleared internally?

I have some NavMeshAgents in my game and every so often, one of them will get stuck. It appears that the agent's path is getting cleared out from inside the Agent update function. It appears to happen only after stopping and resuming the agent at least once.

I have tried the following things to remedy the problem:

  • Use SetDestination()

  • Use .destination

  • Use CalculatePath() (comes back valid) and then set .path

  • Use CalculatePath() (comes back valid) and then use SetPath

  • Detect whether the destination is not what I set it to and set it using SetDestination()

  • Enable & Disable the NavMeshAgent instead of using Stop & Resume

  • Destroy and recreate the NavMeshAgent when I detect the bug is happening

But none of this fixes the problem. The following update frame, pathPending is set to false and the path is cleared out. The 'corners' of the path (which was a straight line, 2 points of current agent position and destination when made with CalculatePath() and set with SetDestination()) now only contains the current position of the agent.

I've checked that ResetPath is not being called. The destination and path of the agent are not being changed by my scripts anywhere in between my setting the desired destination and the path being destroyed.

Has anyone seen this kind of behaviour before? Is this a new bug? I'm on 5.3.2p2 (for Particle resetting fixes). I've also tested on 5.2.4f1 and had the same behaviour.

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
2
Best Answer

Answer by josh_s_dev · Feb 19, 2016 at 06:38 AM

It looks like the answer is "make sure your nav mesh is correctly baked". Apparently my nav mesh was corrupt or otherwise incorrect.

I've created a script to avoid this happening again. This causes Nav Meshes to get baked when you save the scene.

 public class BakeNavMeshOnSave : UnityEditor.AssetModificationProcessor
 {
     public static string[] OnWillSaveAssets(string[] paths)
     {
         foreach (string path in paths)
         {
             if (path.Contains(".unity"))
             {
                 UnityEditor.NavMeshBuilder.BuildNavMesh();
             }
         }
 
         return paths;
     }
 }
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 Mr-Slat · Jul 22, 2018 at 10:14 PM 0
Share

Please help me. Is OnWillSaveAssets called from within the editor? Because I made a Debug.Log and nothing's put out to the console.

For anyone else seeing this the namespace changed to UnityEditor.AI => UnityEditor.AI.Nav$$anonymous$$eshBuilder.BuildNav$$anonymous$$esh();

avatar image Mr-Slat · Jul 22, 2018 at 10:17 PM 0
Share

I'm having the same problem. Agents path resets to their current position. I'm not sure if this code solves the problem I've tried but they still get stuck.

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

43 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

Related Questions

SetDestination doesn't work after building (with images) answer please 0 Answers

What would cause result from Calculate Path to differ from SetDestination 1 Answer

How to make a NavMeshAgent move in the direction it is looking? 4 Answers

NavMesh agent moving to unassigned target 1 Answer

NavmeshDestination not changing. 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