- A* version: 5.3.2
- Unity version: 2022.3.27
Hello!
I’ve got some decent sized maps (around 800x800 maximum) in size, and at times, (a max of) 300 agents all trying to navigate to the player (always over a shortish distance). I was using a grid graph before, but I am in the process of trying to optimize all of my pathfinding stuff and so I am trying to switch over to a recast graph.
The problem: My player can potentially find gaps in the graph and by entering those gaps, all enemy agents stop seeking them.
The obvious solution is to adjust agent radius/voxel size to close those gaps, but the best I can do for an acceptable functionality is a 0.3 character radius, and a 0.15 voxel size, the result of which can be seen below. Those sizes seem well below the default settings, and I get a little warning about scan time, so not sure how much optimization I am losing at those settings (I am caching the graphs, so not worried about initial load times).
Even still, if a landmass is near enough another landmass, it creates a space where there is no graph, but in which the player could fit. I can certainly solve that with some level redesigning, but first I wanted to be sure there are no other solutions I am missing. Also just slightly concerned I will miss a spot and create a bug, it’s not exactly easy to review a map this big to find every possible gap.
Really, my goal is simply for the agents to keep seeking the player. If there’s some sort of way to fudge it to where they will still seek them, even outside of the graph, I’m open to that. Or if there’s a better way to configure this graph (settings shown below). Just looking for ideas, or maybe information I lack. I am also not sure at what point the benefits of recast over grid graph start to flip, or if there’s an easy way to take a guess, such as the voxel/tile count vs the grid graph. (Obviously I can profile it, which I have done a little bit, and it seemed to be faster, but Unity’s profiler is a slog to use and having to do it repeatedly after every settings tweak is a bad time lol, would rather look at some rough data, and then profile it once I think I’ve got “ideal” settings).
Thanks!
Edit: Also curious if going low in the agent radius/voxel size settings has an impact on actual runtime performance, or if that only slows the initial scan (which will be irrelevant if cached). Maybe I’m trying to solve an imaginary problem that I can just solve with using smaller sizes in those settings.
Edit2: After a bit of profiling with these settings vs my previous grid graph, the grid graph seems to work better actually… I seem to get about half as many sub-30fps spikes with the same agent load… Verified I am using same thread settings on both (automatic high load, which for me is 16 cores).
I’ve also not mentioned that I am using RVO and AIPath for movement, in case it is relevant. I also tried my grid graph without RVO and with AILerp instead, but my gains there also seemed negligible, and the NPCs seemed to jitter a lot when the game was paused for some reason.
I profiled various spikes to see where my problems were when I started out (using my normal grid graph / rvo / aipath setup). Probably TMI lol, but this is what I was looking at when I started my optimization journey. Movement, though it was among the lowest of spike times, was the most common cause of spikes that I saw. Not sure if there’s anything else on this list that jumps out as an “aha!”