- Home /
Pathfinding solutions for 2D Dungeon Keeper style game
I'm working with a small team on a dwarf fortress/dungeon keeper style game. We have some experience writing A* algorithms for other projects. We have not been 100% happy with the results and would like to use something built in to Unity or code that is available on the web.
The game map is a grid exactly like dungeon keeper where grid squares are made dynamically walk-able by being mined or dug out. This seems to rule out Unity's navmesh because it is baked at design time and not run time (unless the nav mesh can be applied to an individual grid square and agents can pass over a network of different nav meshes).
Is A* Pathfinding Project overkill for this? Does anybody know of an example or tutorial that covered a very similar example?
@wharris84 did this game ever go anywhere? Just curious how far you guys got. I'd love to know.
Answer by DubstepDragon · Feb 27, 2014 at 05:02 PM
Perhaps you can use the NavMesh pathfinding system. It's built for Unity Pro only though :/
I don't have much experience with the Nav$$anonymous$$esh, but my understanding is that it cannot be modified dynamically while the game is running. Is that correct?
Answer by Levocakes · Feb 27, 2014 at 06:54 PM
I have never used NavMesh before because it is only available in Unity Pro like DubStepDragon said. I had to implement A* into my FPS just a couple days ago. I think A* would be a perfect idea for your game and it would not be overkill. At the start of your game you would have defined nodes and when a block gets removed it would add to the node list of walkable area.
Answer by KrisSchnee · Mar 13, 2014 at 04:15 AM
Seconding Levocakes. The A* algorithm is pretty simple to implement. Here's my code for it in Python (public domain):
http://kschnee.xepher.net/code/080721a_star_pathfinding.zip
The code uses the Pygame library to draw graphics, but you can ignore that and just look at the AStar class. Should be possible to adapt that to Boo or just copy the concept of it.
A* assumes complete knowledge of the terrain, but you can pass that info along to the algorithm whenever you want to run it, even during run-time.