Yesterday I wanted to improve the corridor generation by actually using a path finding algorithm instead of the hard coded mess I had before. While looking for path finding solutions in the asset store, I found a whole bunch of AI solutions – not exactly what I need right now but they looked interesting so I spent two hours looking at them. The most interesting seem to be Rain{one} and the A* Pathfinding Project. Both feature path finding and recast based nav-mesh generation. Rain{one} also comes with environment sensing, behavior trees and integrated animation control while the path finding project seems to be more optimized if you just need path finding. But, as I don’t have a game concept yet and I don’t need AI or navigation meshes right now, I ended up using an old-school open source C# A* implementation for grids. It is well designed and has many options for tweaking. Having the source to the implementation is a big bonus, too, since I later want to make corridors that are several tiles wide and no standard A* implementation can generate wide paths.
So, equipped with this new tool I can now connect rooms that are not right next to each other – the path finder is able to map out corridors between any two points on the map. I forbid the finder to use diagonal movements and I enabled the direction change penalty which makes it prefer generating straight lines instead of zigzag corridors that it generated to substitute for the lack of diagonals. Another set of tweaks was added to the weights in the grid. Basically, I told it to avoid making corridors directly next to a room’s wall and to prefer to make corridors right next to existing corridors. The last tweak tends to generate some wider corridors in areas where a lot of rooms are next to each other. As long as I can’t just outright tell it to make corridors with three tiles width, this is the next best thing.
While I was at it, I changed the look of the rooms’ walls and added automatic doors to the room exits.



