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?

As found by googling NavMeshAgent:



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?

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

lets take this with an example
you need to buy milk bottle now you have 2 choices.
if you take left side direction from your house there is only one shop you can buy the milk bottle. but what if that shop is close you will come back home with an empty hand this is navmeshAgent.destination
2)if you take right side direction from your house there are more than 1 shops in case if that one shop closed you can buy from another shop. you can handle that situation. this is navmeshAgent.setDestination because it return true or false so you can use if condition if it return false then whats need to happen you can write logics. but navmeshAgent.destination only set the path it wont return what if there is no path. so you cant hand what needs to happen next.