Enemy navigation issues

4.1


my enemies will walk through the water to get to me which ends up in them getting stuck, you can see that my navigation region should only be allowing them to walk on the islands and bridges. My conclusion is that they pathfind but they only move toward strait toward the player. I reached this conclusion after in another maze like level they would consistently get stuck on the walls.
what do I do here? thanks in advance

also code will be provided


Could be the target_distance to loo long, the default values are kind high and cause a lot of problems.

Try to reduce the path_desired_distance and the target_desired_distance to a smaller value… maybe even 0.1 just to see if it works

You might also need to adjust the size of your agents in the navigation mesh and recreate the navmesh. This can help prevent navmesh being created too near the borders where they are likely to get stuck.

There are other nuanced configuration that might be the issue, but those two are the simplest ones, and usually can solve most problems.


Also, strange way you use to get the current location.
You can try using: var current_location = global_position, its shorter and makes more sense when reading the code.

I made my pathfinding distance 3 and it seemed to work fine, I also did the other stuff you recommended so thanks!