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 Ziron999 · Feb 20, 2015 at 11:37 AM · c#javascriptnavmeshnavmeshagent

Navmeshagent stops with destination set

For some reason when the units are moving they get stuck and collide at the edge of my concentric circle. When i click once and do nothing they clump up and never continue to the navmesh destination set from the info below...why do they stop and not continue to the location...if i put MovePlayerToDestination in update it works but obviously that would not be the way to do things. From my understanding both .SetDestination & .destination = should keep going until they have reached their destination why do they stop??? ulgh frustrating problem...:(

alt text

 void MoveToMouse()
     {
         Plane plane = new Plane (Vector3.up, transform.position);
         rayToMouse = Camera.main.ScreenPointToRay (Input.mousePosition);
         float dist;
         plane.Raycast (rayToMouse, out dist);
         if (Physics.Raycast(rayToMouse, out hitTag))
         {
             //need owner check before interacting with planet options
             //if (hit.transform.tag != "Planet")
                 MarkerGO.transform.position = hitTag.point;
         }
         MovePlayerToDestination();
     }
     
     public void MovePlayerToDestination()
     {
         for (int i = 0; i < GlobalLimit; i++)
         {
             if (PlayerUnitCache[i] != null && PlayerUnitCache[i].activeSelf)
             {
                 if (MarkerUnits.Count > 1)
                     CreateConcentricCircles(i+1);
                 
                 if (PlayerUnitCache[i].transform.position != MarkerUnits[i].transform.position)
                 {
                     if (MarkerUnits.Count > 1)
                     {
                         MarkerUnits[i].transform.position = new Vector3(pos.x+MarkerGO.transform.position.x, 0.012f, pos.y+MarkerGO.transform.position.z);
                     }
                     else if (MarkerUnits.Count == 1)
                     {
                         MarkerUnits[i].transform.position = MarkerGO.transform.position;
                     }
                     //SetDestination stops if something is blocking the path.
                     PlayerAgentCache[i].destination = MarkerUnits[i].transform.position;
                 }
             }
         }
     }
     
     // Update is called once per frame
     void Update ()
     {
             if (Input.GetMouseButton(0) && !RTSCamera.dragging)
             {
                 Invoke("MoveToMouse", 0.12f);
             }
             else if(RTSCamera.dragging)
                 CancelInvoke("MoveToMouse");
     }


badbug.jpg (38.1 kB)
Comment
Add comment · Show 4
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 siaran · Feb 20, 2015 at 01:56 PM 0
Share

Not really sure what's going on, but a few things about navmesh agents that might help you solve it (I'm assu$$anonymous$$g you're using Unity's built in NavmeshAgent:

-You can check for agent.remainingDistance, this should give you the remaining distance to the agent's destination.

-agent.path gives you an agent;s current path. You can check path.status to get it's status (PathComplete, PathPartial or PathInvalid). $$anonymous$$aybe your agents only have partial paths.

-You can use agent.CalculatePath to calculate a path for the agent to a destination without it actually moving there.

-You can also use path.corners to get all the corners of a path, you can use it to draw debug lines for your paths so you can see how the path goes (and where it ends).

Sorry, I don't really have an answer but I hope this helps you anyway.

avatar image Ziron999 · Feb 20, 2015 at 06:48 PM 0
Share

Is there a way to force destination even if a path is blocked? If i put just:

 for (int i = 0; i < GlobalLimit; i++)
         {
             if (PlayerUnitCache[i].transform.position.x != $$anonymous$$arkerUnits[i].transform.position.x && PlayerUnitCache[i].transform.position.z != $$anonymous$$arkerUnits[i].transform.position.z)
             {
                 PlayerAgentCache[i].destination = $$anonymous$$arkerUnits[i].transform.position;
             }
         }

in update it does work

avatar image siaran · Feb 20, 2015 at 07:16 PM 0
Share

Not sure what you mean by 'forcing a destination if a path is blocked'. I suppose you could store the vector that you had set as destination, then check when your agent's remaining distance is 0 if it's at/near the destination you had set, and if not, do something (You could warp it to the destination you had set using NavmeshAgent.Warp for example.)

...Or maybe you should turn on agent.autoRepath? Have you read the NavmeshAgent API? Here's a link: http://docs.unity3d.com/ScriptReference/Nav$$anonymous$$eshAgent.html It really helps to read the documentation of these things.

avatar image Ziron999 · Feb 20, 2015 at 07:34 PM 0
Share

Ya honestly i only know how to use destination when it comes to agent's i've never used any of the features you are talking about and don't really know how they work yet lol I tried autorepath it didn't do anything noticeable. I tried a distance check and the units do not reach their destination at least now i know it isn't a problem with them going to the wrong location...

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Ziron999 · Feb 20, 2015 at 07:50 PM

Answered my own question it's because the waypoint destinations had a collision sphere on them...apparently this was just enough for the units to hit the sphere and then stop but if navmeshagent destination is in update i guess it forces the navmesh to go through a collision. Deleted the collision sphere and it works fine luckily they are just waypoints and don't need a collision anyway in this case...

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

21 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

Related Questions

NavMeshAgent object jumps 0 Answers

How to queue NavMeshAgents on entering a tile in Unity (based on path distance to tile)? 0 Answers

How to prevent NavMeshAgents from colliding when warped to same position? 0 Answers

NavMeshAgent resume original position and facing direction C# 0 Answers

How to make NavMeshAgents traverse two possible paths 1 Answer


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