How to stop a Navmeshagent from teleporting when the navmesh overlaps in Z

I’ve been trying to use the NavmeshAgent to create some minion characters that follow the player around in 2D sidescroller game.

One of the biggest issues I’ve found with this is that if a NavMeshAgent is pathing to a destination and passes a place where the Navmesh overlaps in the Z direction it will teleport in the Z axis to the destination instead of going around to the OffmeshLink which it should be using. Hopefully this picture will help you see what I mean.

I’ve noticed that the Navmeshagent will only exhibit this behavior if it either has no Rigidbody attached or the Rigidbody is set to be kinematic. However giving the agent a non-kinematic rigidbody adds a whole other set of problems where the physics and navmeshagent seem to interfere with each other.

Has anyone else experienced this teleporting behavior with navmesh areas that overlap in Z? Can anyone point out what I’m doing wrong here?

I seem to have found a workaround to the problem. I don’t use off mesh links, instead I handle movement manually for the transition between two planes. So let’s say I have my minion walk to the edge of the navmesh, then teleport to the other navmesh plane. But this way, it appears that when you teleport a minion to a new plane, the navmesh agent still thinks it is on the previous plane.

I couldn’t figure out how to tell the navmesh agent which plane it should think it’s on, but this is how to trick it to work:

//disable everything agent related
navmeshAgent.Stop(true);
navmeshAgent.updatePosition = false;
navmeshAgent.updateRotation = false;
//this is the most important part; turn the agent off:
navmeshAgent.enabled = false;

//do your nasty teleporting/flying stuff
teleportMinion();

//restore everything
navmeshAgent.enabled = true;
navmeshAgent.updatePosition = true;
navmeshAgent.updateRotation = true;

This should work regardless of where your two separate navmesh planes are in relation to each other.

I am still curious to see how to actually control how the agent decides to use the off mesh links, but for now this will have to do.