NavMeshAgent Warp returns false on a successfully sampled position

Here’s the code I tried :

NavMeshHit hit;

if (NavMesh.SamplePosition (transform.position, out hit, 2f, NavMesh.AllAreas)) {
       Debug.Log(_agent.Warp (hit.position));
}

In some places it somehow prints false.
My question is, what are the things that causes a Warp() to return false? The documentation isn’t clear enough and doesn’t explain it, so I presume it will return false if the Warp parameter is not on NavMesh
. But in my example, the point is clearly on NavMesh, because I used SamplePosition to retrieve the point, and it’s no doubt successful (the SamplePosition returns true). I’d really appreciate if anyone can enlighten me on this, thanks.

Are you using the default navmesh agent type on your error-producing gameobject? I had this a while ago and it ended up being down to me trying to use a customised navmesh agent for the bug-ridden objects (pigs, in my case) and it started working as intended when I set the pigs to use the default navmesh agent like all the others did.

There is probably a better solution that would detail what you need to do with a custom navmesh agent, but my solution worked in order to get my pigs correctly warping to a correctly loaded navmesh.