Enemies getting caught while navigating around obstacles.

Godot Version

Godot 4.3

Question

i’m having an issue where the collision shape for my trees exede the tile size on my tileset which means that when the dogs/other enemies try to pathfinding around them, they occasionally get caught as you can see here:


while i could just change the size of the collision shape for the tree, i don’t really want to since that would mean the dogs, player, and other entities would be able to pass right through some parts of the sprite. Currently i’m using a navigation agent 2d and a navigation layer on my tileset to control the dynamic pathfinding of the NPCs and enemies.

It’s been a hot minute since I’ve worked with nav layers and nav agents, but I faced a similar issue when I was working with these things. I have two ideas: (i) increase the “avoidance margin” or whatever it’s called, in the navigation agent’s settings. (ii) Manually cut an area equal to or larger than your tree’s collisionshape out of the nav polygon. You can of course add this process to a script and extend collisionshape to some nav_avoid_collisionshape node type if you plan on using a lot of these.

Since i’m using a nav layer, i don’t think i can cut a shape out the nav polygon and i couldn’t find the “avoidance margin” thing, so how would i add a nav_avoid_collisionshap? or if you know where i could find the name of the avoidance margin thing that would be great as well.