How to stop the AI moving into a wall in 2D?

I’m following the doc to give the AI a Wandering behavior and tweaked a bit to suit my needs.

The problem is the point picked to wander sometimes inside the collision area and the AI walks non-stop into the wall.

Is there a way to prevent this? Sorry, I just recently used this pathfinding project.

Hi

Maybe this tutorial will help you: Wandering AI Tutorial - A* Pathfinding Project