How to stop an AI when it can't reach it's destination?

Hi all,

I was wondering how do I stop an AI (force it to go idle and wait if it’s trapped, or return to patrol) if it can’t reach the player or a patrol point, because of an obstacle or broken nav mesh?

Can’t seem to find anything relevant with searches. Any help much appreciated!

2 checks: the velocity of the AI is greater than zero (to check if it’s stuck) AND whether I’m inside the navmesh limits (x,y).

If any of the 2 conditions are false, then send the AI to do something else.