How do you access the NavMesh object from script?

I’m putting together a simple navmesh & navmeshagent test and things seem to work i.e. calling SetDestination on the navmeshagent makes him path intelligently to that point.

Now, I’m wondering how do I get a reference to the navmesh object itself so I can call methods like SamplePosition() etc.?

Thanks!

NavMesh is a static class and holds a reference.
Or you can create a public variable of type NavMesh, and assign it the NavMesh object in the asset library, which is the nav mesh object.

In either case, I’m having a problem where SamplePosition is returning (infinity, infinity, infinity) which is unhelpful.

So either I’m wrong in answering your question and I, too, need to know, or that I’m right, and I’ve got some other issue entirely.