Pathfinding is operational. The rats intelligently pick new routes to flank the player and avoid congestion in the long term. What they don’t do very well yet is avoid clogging up the doorways when they’re already bunched up. They also unnecessarily zigzag a bit, slowing them down and making them look just a bit more insane.
I have an idea I’m going to try tomorrow that might fix the clogging around doorways. The monsters will have access to a traffic map that tags each tile with a movement vector. They all start out neutral, and when a monster moves into a tile, that tile’s vector is set to match the same direction as the monster’s movement. When inside a tile, a monster has to move along with the current, or vacate the tile. Currents get reset with a timer, so if a monster hasn’t walked on the tile for a few frames, it gets neutralized.
It’s an unusual system, so I don’t know if it’ll work yet, but it’s worth trying.
To fix the zigzagging, I can set the monsters to keep a course for longer. Once they are in sight range of a hero, though, the zigzagging will stop because they stop pathing altogether at that point.
Nice post ! I like the idea of sharing some thoughts while the dev process. Thank you, It\’s really interesting !
My pleasure! It is actually helpful to me to blog about my progress, because it forces me to think about how I am spending my time. Glad it makes for interesting reading as well.