I spent the last week replacing the Pathfinding AI from a 3rd party library (Astar Pathfinding asset for Unity) to my own. The Astar library is great for all the pathfinding AI it provides. However the requirements for Dofense are a very small subset of them. The Astar API is too high level to do some optimizations. Moreover its Asynchronous nature made the code unnecessarily complicated.
I've written many simple path finding solutions for Tower Defense in the past 3 years. I had chose Astar over them because I thought its visualization gizmos will be a good feature to have and I won't have to debug issues at low level. But over the time that benefit wore off. In certain maps I saw the library failing to give correct results and I couldn't find the root cause. I tried some workarounds, which were ugly due to the asynchronous nature of the code. So I finally decided to switch back to my home made solution. I would still use Astar in future for other projects, if there is a need for more advanced pathfinding. But for now I'm happy to use my custom little library for Dofense.
The new code will fix a lot of pending issues. You may have seen them sometimes in the form of stranded enemies walking all over the map without regard to the towers and terrain. Those issues will be fixed after this update. Moreover I expect some improvement in performance too. That will enable large crowds of enemies without slowing down the game.
Here's a picture of the under-the-hood view of a typical map for your viewing pleasure.
![](https://www.eprison.de/pics/games/https://clan.akamai.steamstatic.com/images/35389079/c57c0b4f16853cb2a63d1d72a55c0c35f1ebf1a7.png)
Have a great weekend!