Pathfinding
Published on: 2025-07-08 11:32:15
#9 - Pathfinding
Hello!
I've recently been working on the pathfinding for NPCs in my game, which is something I've been looking forward to for a while now since it's a nice chunky problem to solve. I thought I'd write up this post about how I went about it all.
I had a few extra requirements of my pathfinding, due to how my game plays:
Must deal with a dynamic physical environment (objects can move freely and are destructible)
Have paths that prefer to keep their distance from objects but still get close when needed
Allow for wrapping around the borders of the game area (Asteroids style)
General Approach
My first thought was that I wanted detailed paths so that they could thread through messy arrangements of objects quite easily. This would mean a longer search time, so the simple choice of search algorithm is A*. And since I need to query the world for each node to see whether it's blocked, I thought I'd use space partitioning with the queries to cut down on the number req
... Read full article.