2D Obstacle Avoiding Enemies In 2D - TopDown Dungeon Help

Hey everyone,

I’m currently making a top-down dungeon crawler where enemies chase after the player, but there are obstacles around the room that they get stuck on when following their path to the player.

I’ve tried to use ray casts and make them decide between moving left or right to avoid obstacles, but that doesn’t seem to be the perfect solution and multiple enemies get stuck on each other or get stuck in a continuous dodge loop where they keep detecting each other.

These guys here are getting stuck (highlighted in red). I was wondering if anyone had any ideas of methods to get around this?

Hi,

have a look at the Unity NavhMesh system. This might be a little overhead for your solution, but you don’t have to reinvent the wheel, aka pathfinding and collision avoidance :slight_smile: