Big world + local areas

Imagine I have a massive 3D open world where agents are walking around using roads.

Then I have certain areas that are towns. A lot of pathfinding is going on in towns, from town to town using the roads etc.

Outside these towns are farming fields. Now I want an agent to be plowing this field from corner to corner, and this field is one mesh itself. In this mesh, I am thinking of adding points/grid where all the plants go, so it may be a 50x50 field with each tile being one plant for example so I know where the AI will animate the work.

Would an irregular field mesh work the same way?

Is it possible to create a custom graph for this field alone, so the agent doesn’t search outside of it unnecessarily to find the next node to work on? Like, as long as the agent is plowing, sowing, harvesting the field it doesn’t need to go outside of it searching where to go in the open world. But when he is done he should pathfind to his house to go sleep.

Now multiply this with 100’s of farms and agents and it should be done in a performant manner.

And what about having 2 farmers working on the same field, how do you not have them bump into eachother without having to use local avoidance? Can I reserve one of the tiles for one agent, so the other agent does not bother moving to that tile if another agent already claimed it before moving there?

Is this possible?

Also in relation to travelling on roads between town to town, to avoid pathfinding across the entire massive terrain everytime into grass and forest areas. Imagine a caravan travelling back and forth regularly. The path is already known from the beginning of the games start, A to B coordinates. Can you cache this path to avoid recalculating it for the caravan agent everytime it starts its journey?


Farms: The system for who gets to put crops where, who farms on which farmland, and so on, should be a separate program. The only thing A* should be involved in, is setting ‘This object’ should go to ‘This place’.
But if you need help with how to do that post/check out Unity’s forums. Many people there have probably done what you do now.

If your world is fixed in place, generating a graph for the entire world would be much easier.
If it is massive enough, that your PC can’t handle all the graph data loaded at once, you can save/load data when needed.
Yes, it is possible to setup two objects moving aside for eachother.
This would be useful for the caravan as well. Don’t worry about setting an A to B- type path, unless you want it to go a very specific, and not nessecarily the fastest path.
And this A* tool is extremely fast, so hundreds of agents shouldn’t be a problem.


I’m not quite sure about the best solution here, as I don’t know much about the scale of this game.

My initial gut feeling is to use a single static recast graph for the whole world. That would be the simplest solution if it works.
I’d avoid having hundreds of graphs unless you really need to. That many graphs tend to be very annoying to manage, even though it is possible to have up to 256 graphs.

There’s no built-in code for this. Reserving tiles and such is something that you’d have to include in your game code.

It is possible to calculate a path once and feed it to multiple characters. But I would strongly recommend profiling first to see if this is a problem in practice. It is much more convenient to allow agents to recalculate their paths whenever they need to.

I’m not quite sure what you mean by this?

I am interested in the FollowerEntity for ECS solution. Which I will probably need considering the amount of agents I will have.

But I can’t find any information on how to apply lower cost on roads. On Unity Navmesh I use Navmesh volume modifier and lower the cost on my roads on terrain and the AI does follow it instead of walking offroad even if the offroad path is shorter.

Also how would you handle buildings or meshes that can be placed by players where the player has to enter the door and be able to walk inside? Plus multiple floors?

Can this package utilize the standard Unity prebuilt navmesh?