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 NoUJoe · May 06, 2014 at 02:45 PM · navmeshnavmeshagent

NavMeshAgent.destination vs SetDestination ()

What is the difference? I find there is a lack of detailed information on NavMesh. At the moment, I am using .destination to set an agents destination. I'm also setting this every frame which I presume is bad because I think it calculates a path every time it is set. So should I only be setting its destination once?

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
2

Answer by castor · Jul 08, 2016 at 08:56 PM

From what I understood, the main difference is in what both return. The major one being, if you set a destination to an invalid position (e.g. not in the Navmesh) you can handle the case with SetDestination(), but not with NavMeshAgent.destination.

If it's not possible to find a valid nearby navmesh position (e.g. scene has no navmesh) no path is requested. Use SetDestination and check return value if you need to handle this case explicitly.

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 xortrox · May 06, 2014 at 02:57 PM

As found by googling NavMeshAgent:

NavMeshAgent.destination

SetDestination

Telling by the documentation, when SetDestination is used it does pretty much the same, however reading the SetDestination documentation:

Note that the path may not become available until after a few frames later. While the path is being computed, pathPending will be true. If a valid path becomes available then the agent will resume movement.

So simply dont set the destination if NavMeshAgent.pathPending is true I guess?

Comment
Add comment · Show 4 · 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 NoUJoe · May 06, 2014 at 03:27 PM 0
Share

I've read the documentation but it just isn't clear enough. Surely both .destination and SetDestination will have to calculate a path? It doesn't make sense that one would and one wouldn't.

avatar image xortrox · May 06, 2014 at 03:35 PM 0
Share

It seems they both do, you can check this by altering destination and then checking if pathPending is true, then once pathPending is no longer true try SetDestination and then check if pathPenging is true, if it's true both times then you will know they both do the same.

avatar image tanoshimi · May 06, 2014 at 04:09 PM 0
Share

Either way, you definitely don't want to keep setting the destination in the Update() loop. Just set it once, and then only set it again if the destination changes.

avatar image Brogan89 · Jun 26, 2015 at 03:57 AM 0
Share

so based on that? is it better to have AI chase a playerObject with SetDestination() because it will also be changing? .destination is better for static objects?

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

23 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

Related Questions

Nav mesh if agent was above the ground 1 Answer

How to move object to transform.right with NavMeshAgent 0 Answers

Stop NavMesh Agent from getting stuck 0 Answers

Can't get NavMeshAgent move. NavMeshAgent ignores destination property 7 Answers

Navmesh error on instantiated navmesh agents 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