I'm trying to set my game in a city dynamically generated from a seed. Each city block would be considered a chunk, and chunks would be loaded and unloaded based off of something like their manhattan distance from the player.
However, I'm not sure how I'd handle AI moving between chunks. Since, in theory, I could make the city generation infinite, I'd also need to have what essentially boils down to an infinitely-sized NavMesh. I was thinking about handling the NavMesh on a chunk-by-chunk basis, but I'm not sure how well Unreal's AI handles "bridging" between two NavMeshes.
There were a few options I was thinking about trying, in order of preference:
Each chunk is its own level and they are streamed them in as needed, using the tricks mentioned here to handle loading the same chunk twice. I'm slightly concerned about the performance hit that something like this would cause, but it would likely offer me the most control and flexibility and would also allow me to easily organize any chunk "prefabs," as it were. Each sublevel would have its own NavMeshBounds to handle AI within that sublevel, but I'm not sure how well moving AI between sublevels would work, if it works at all.
Each chunk is a hierarchy of Actors that make up a chunk "prefab." There would be a NavMeshBounds in each chunk's hierarchy that would generate the navmesh after the chunk actor gets placed. This wouldn't have to deal with streaming in any levels, but I'd still have to work out how to "bridge" between the navmeshes on a chunk boundary.
Have a NavMeshBounds centered on the player's current chunk and expand it out in all directions in the size of n chunks. If the player changes chunks, it would move to be centered on the new chunk -- the same sort of system that gets brought up in this question here. This dodges the problem of bridging navmeshes entirely, but I'm not sure what would happen to AI caught "outside" the navmesh when it's regnerated. Do they use the "old" navmesh data, or do they act as if they aren't on a navmesh at all?
Simply changing the bounds of the NavMeshBounds. This seems like it might have a pretty major performance impact, however, since the size of the navmesh could grow fairly dramatically as the player wanders away from the origin of the NavMeshBounds. I'm also not even sure if changing bounds size at runtime is possible.
I haven't really even gotten beyond the planning phase of how to best handle the world generation system, so I'm also open to any other suggestions anyone has for how to best handle AI and procedural generation.
Mar 25 '15 at 08:18 AM
in Using UE4