Real-time Pathfinding for NPCs in a Dynamic Game World
2025-05-15

This post details a pathfinding algorithm for NPCs in a game with a dynamic physical environment (objects move and are destructible). The algorithm uses A* search with space partitioning for efficient querying of the game world. It handles path wrapping around the game boundaries, and incorporates a proximity rating to prefer paths further from obstacles. Real-time updates are managed by caching node states and periodically invalidating the cache. Pathfinding is split across multiple game ticks to maintain performance. The author prioritizes a self-implemented solution over readily available online examples, emphasizing the learning and problem-solving aspects of game development.
Read more