Enemy stuck to corner when chasing player

I have used the free version of the A* pathfinding algorithm for my game’s enemy to chase the player. When the enemy makes a turn it tends to get stuck. I am not sure if the problem is with the settings or there is something wrong with the code or collider. I have attached a gif to show what I mean. The script for the enemy is based on the example given on the website with rigidbody velocity for movement control.

Should I make corridors bigger? Is it possible for the algorithm to make the turn wider so that enemies won’t stuck to wall? Or make path not stick too close to the wall?

Any advice would be appreciated. Thanks!

Edit: I have included the AstarAI code here.


It’s hard to say what the problem is just from that gif, but it looks like some collision problem. Try to check if turning off collision helps (unity settings -> physics).