How to make enemy avoid walls?

I’m making a top down 2D game, and enemy has to chase the player. But even when the player is behind a wall the enemy is trying to walk through it, but the collision stops it from walking through the wall. How can I make the enemy walk around the wall or avoid it in any other way?

Check out this unity tutorial on how to define a so called nav mesh and AI that navigates the mesh. This should get you started in the right direction.

I did something similar and basically had the nav mesh agent go to the player position using the destination property and on collision with the player marked him as “caught”.