The elegant solution would be to have areas around the edge of the nav mesh that ai won’t go onto voluntary, but they can leave. Call them margins. I’m shocked that it’s not a standard feature.
I tried making some using obstacles. I lined the outside wall of a 400 x 400 nav mesh with Obstacle mesh modifiers. But they still walked right on through.
Next, I brought them in so there was still a navigable ring around the outside, like so:
.----------------------------------------------------
-88888888888888888888888888888888888888-
-8------------------------------------------------8-
-8------------------------------------------------8-
-8------------------------------------------------8-
-8------------------------------------------------8-
-8------------------------------------------------8-
-8--------------------------------------------------
-88888888888888888888888888888888888----
.-----------------------------------------------------
I hoped they’d turn back and try to escape through the bottom right corner. But they walked right over the obstacle like it was nothing. And then, of course, they froze forever.