I’m making a tower defense game where the AI has to find a path through a maze of the player’s towers and blocks. The AI should always try to take the shortest path so that the player can plan around predictable behavior. Here is a picture of the problem I’m having:
The green area is the navmesh. With no obstacles, the AI always tries to take the shortest path from waypoint 1
to waypoint 2
. If I place block 1
, the AI still takes the shortest path as expected. But for some reason when I place block 2
, the AI wants to travel all the way around block 2
even though it has a shorter path. After placing block 3
, the AI goes back to a straighter path, but it’s still crooked.
Is there a way to make AI always take the shortest path?