Hit Box Prevents AI Navigation to Goal Location

I’m working on a town management game where NPCS walk to resources nodes, trees rocks, etc and attack them for resources. Problem. The only way I can get my AI to navigate to the nodes is to completely shut off all “Can affect navigation” This allows AI to walk to the spot, but now they bash into walls rocks and trees because it’s not affecting the navigation anymore.

I changed the navtype to Dynamic obstacle but they still walk straight into everything.

You need to check (and show us) the resulting navmesh generated in both cases. (press P)

Make sure the start and end points for each request are on that navmesh otherwise it won’t work.

How do I make it so the AI can get as close to the tree as possible. And don’t have to turn off the affect navigation, because the AI will just bump into trees when walking if I turn it off.

You could probably just raise the acceptable radius on the moveto command. Like if your trees have a 50cm radius and moveto is sending them to tree’s absolute world loc, up the acceptance radius to 60 or 100, and incrementally dial it down if they’re stopping too far away.

Alternatively, you could add an arrow component or something to your resource actors, mark it as hiden in-game and place it at the relative/local location you want NPCs to harvest from. Then in your behavior tree or state tree task where you set the move to location, get the arrow component from the resource actor and use its world location for the moveto. This will give you more control to line up the mining/chopping animations too.

I use something like this is my game for furniture to line up animations with the meshes. If you don’t have a traditional player pawn, you could also try the Smart Object system.

Forests are hard to navigate. Imagine that the NavMesh shows where the center of your actor can be. The hole seems bigger than the tree because it is the size of the tree + the size of the actor.

My suggestion would be to just make the trees not affect the NavMesh. The actors will bump into the trees because of the collision but will path right through them. You’ll have to make sure however, that trees always have enough space between them to squeeze a character otherwise you might have characters stuck.

Do the roots of your trees have collision enabled? The agents should avoid holes in the navmesh caused by the capsule at the center of the tree. You may need to check that the agent radius used for generating your navmesh is the same or larger than your characters. Default radius is 34uu IIRC, but your characters could have a capsule radius larger than that. If that is the case, the agent radius for the navigation mesh should be increased to match. Agents assume all navmesh locations are valid and do not do an extra check for true capsule size against the geometry. I have seen several cases where AI appear to stick or bump into objects or corners in projects and it has usually been that the default radius for the agent is too small.

-James