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
1
Question by Roi Danielsen · Nov 20, 2014 at 01:40 PM · navmeshagentnavigationwaypointroute

Why does the NavMeshPath.corners only contain 1 waypoint?

Hello.

Im trying to get the path that my NavMeshAgent is following, and I read in the script reference that NavMeshAgent.Path is what I want.

I read on, and saw that the Path is stored as Vector3 array, in NavMeshPath.corners.

However, as I tried to spawn spheres at all the vector3's in the array, to my amazement it only spawned 1 or 2.

I want the full path, so I can show my player the route of the player character before he starts moving, but I can only ever get 1-5 waypoints, although sometimes it give me up to 20 waypoints from the NavMeshPath.corners array. The only waypoint is the actual destination, and not the full path, even though my agent navigates perfectly through a whole maze.

What is going on here? I might have misunderstood something, or maybe the unity pathfinding is simply so brilliant it only needs 1 waypoint?

Anyway, some info on this, or perhaps another way of doing it?

Here is the function for good measure.

 void DrawPath(NavMeshPath path)
     {
         Debug.Log(path.corners.Length);
 
         foreach (Vector3 point in path.corners)
         {
             Instantiate(waypoint, point, Quaternion.identity);
         }
     }
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 MrSoad · Nov 20, 2014 at 12:48 PM 0
Share

Hi, could you provide the code that is spawning the spheres from the Nav$$anonymous$$esh array info, thanks :)

avatar image Roi Danielsen · Nov 20, 2014 at 12:59 PM 0
Share

Added my sphere spawning code.

avatar image MrSoad · Nov 20, 2014 at 01:43 PM 0
Share

Have you put a Debug line inside the loop to check that it is run the same amount of times as the Length that you print above?

avatar image Roi Danielsen · Nov 20, 2014 at 02:28 PM 0
Share

Yes, and it loops the same amount of times. I do seem to get more waypoints sometimes, and other times it only gives me 1? It's kind of random. I use mouse click to place the player destination, and when I click once, at the end of the maze, i only see 1 waypoint, and that is the first one. If I Spam random locations for him to walk, I sometimes get more, but not the whole route.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Unity Navigation in FixedUpdate 0 Answers

Object with navmesh goes down 0 Answers

NavmeshAgent and NavmeshObstacle and Bake don't work with AICar 0 Answers

navmeshagent.isOnOffMeshLink always false when using navmeshagent.move to moving. 0 Answers

NavMeshAgent Rotate With Model 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