Get Navagent to move upward off the navmesh

I’m making a game with some civilians controlled by navagents on a navmesh, and periodically I need them to be abducted by flying saucers and move off the Navmesh directly upward. However, when I disable the navagent component to move it up, the gameobject continues to move in the direction it was last moving when the navagent was disabled, so instead of moving directly upward to the flying saucer, it moves up diagonally away from it.

I tried adding the Stop() method before disabling the navmesh, but that gives me the error message “‘Stop’ can only be called on an active navagent that has been placed on a navmesh.”

Here’s a code snippet that seems to be the problem. Anyone have any ideas?

if (captured == true)
            {
                agent.SetDestination(flyingSaucer.transform.position);
                agent.velocity = Vector3.zero;
                agent.speed = 0;
                agent.Stop();
                agent.enabled = false;
                this.GetComponent<Rigidbody>().useGravity = false;
                transform.position = Vector3.MoveTowards(transform.position, flyingSaucer.transform.position, abductedSpeed * Time.deltaTime);
            }

Use offMeshLink

Here are a few functions which you can use, in particular inspect “Variables” and “Public Functions”

Also, look into NavMeshAgent API, to be specific, CTRL+F —> have a look at anything with “offMeshLink” inside of it