Stopping player from trying to run through walls? (click to move, sans navmesh)

Hey, Unity people.

I’m working on an ARPG with a click-to-move mechanic. The problem is that if you click outside of the dungeon walls, the character will run into a wall indefinitely trying to get to that outside position. How can I make my character “realize” it’s at a dead end? Bear in mind these dungeons will be generated at runtime, so I can’t make use of navmesh.

Any advice, as always, is greatly appreciated!

Here’s my thinking so far:

Linecast between my character’s current position and the destination. Ignore everything that isn’t a wall of the dungeon. I then set my new destination point to where in the wall I hit. So if a player clicks outside the dungeon, the character will walk to the wall and stop.

Or on a collision with a wall then stop

If I take that approach, I’ll be stopped if I just brush slightly up against the wall, those still count as collisions. But thank you anyway.