When generating a navigation mesh using RecastGraph, I’ve encountered an issue where increasing the MaxStepHeight value causes significant discrepancies between the terrain and the navmesh in areas with pits or holes, resembling a deep-water lake. When using FollowerEntity as the agent, these agents tend to jitter up and down at locations with such discrepancies. Increasing the agent’s height can alleviate this issue to some extent, but if the drop-off is too large, it seems impractical to proportionally increase the agent’s height. Therefore, I am reporting this problem to inquire if there is a better solution. The root cause of this issue is the continuous up-and-down movement of the FollowerEntity, which was not immediately obvious due to the subtle elevation changes in the actual game map. To better demonstrate the issue, I have recorded a video where I set the MaxStepHeight to 1 to create more pronounced discrepancies.
Hi there- sorry for the extra late response! This one slipped through the cracks and I found it when I was checking for unanswered posts. So I went to test this for myself, with MaxStepHeight set to 1 (which is default apparently) and I’m not seeing these issues on my end. If you’re still having this issue, would you be able to send some screenshots of your AstarPath and FollowerEntity settings?
This time, I used the simplest reproducible scene with parameters. First, the scene consists of 25 Unity default cubes, then I scaled them up three times and arranged them in a square pattern. Finally, for each additional inner circle, the height is reduced by 0.5. For plugins, I used RecastGraph and FollowerEntity, and all parameters were set to their default values. The video link is: https://www.youtube.com/watch?v=qwCyfRFLQKw. I believe the issue arises when RecastGraph generates the navigation mesh; it blurs areas that match the MaxStepHeight into a flat surface. When FollowerEntity encounters this pit, due to gravity calculations, it has not yet landed, and there is some mechanism that corrects to ensure that half the height of FollowerEntity is not below the navigation mesh, causing the up-and-down shaking.
Actually, would you be able to ZIP and send that project file to me? Would probably be a lot easier and less prone to reproducing issues than doing it by hand. If you don’t feel comfortable with that, no problem
EDIT: Also I love the commitment to the game on the screen above. Full respect on that one haha
Sure, no problem at all. I’ve started a new project using my current version of Unity and have created the scene to reproduce the issue. Since we don’t use GitHub much on our end, please forgive me for sharing the files via a cloud storage service instead.
Not a problem at all- I actually prefer cloud storage more in this scenario, since I can just download, unzip, and take a look.
I really appreciate this well laid out sample project by the way- it’s very useful. So while playing with it, I’m wondering if this comes down to having the right settings- when I set the voxel size and tile size lower for more dense generation it stops having issues, but on a large scale world I don’t know how feasible that would be, let alone if that’s the intended solution.
I’m gonna tag @aron_granberg on this one, as it may well be a bug, or at the very least he’d have better insight on how a Recast graph is supposed to be able to handle this situation better.
Yes, different game developers may have various settings. I just reproduced the issue using the default settings to help you identify the problem.
As previously mentioned, I feel that this issue is more likely to originate from the FollowerEntity itself, as other Movement scripts do not exhibit this problem. When compared to other Movement scripts, it appears that the FollowerEntity is being constrained to the navigation mesh, which could be the cause of the issue.
Yeah that adds up pretty well then. We’re definitely appreciative of investigations like this by the way. Super helpful information.
Hi
This is indeed an issue.
The FollowerEntity will try to move itself back on the navmesh if it is too far below it.
I’d recommend trying to make the navmesh follow the surface of the terrain at least roughly (not more error than the height of an agent, at least).
You can do this by lowering the tile size in the recast graph settings.
It will also tend to naturally resolve itself once you add a few more obstacles on the terrain that break up the navmesh.
Thank you for your reply. I will first try to adjust the recast graph settings to avoid this issue as much as possible. However, I also hope that the upcoming version of FollowerEntity can be exempt from this limitation like other agent scripts.
Did you find a way to improve the jittering other than decreasing the tile size and voxel size?
I set my tile size to 16 to fix it and this slope is not even too steep.
Or I set my tile size to 32 and voxel size to 0.25.
My FollowerEntity jitters on basically any sloped terrain.
I didn’t find a better solution either. Besides using a smaller voxel size, you can also directly increase the height of the agent. The correction is not based on the agent’s full height but rather half of it. Of course, I believe that to truly solve this issue, the best method would still be to remove the logic that pulls the FollowerEntity back to the navigation mesh, or to add a boolean option to choose whether to enable this feature. However, this requires modifying very core parts of the system, which I am not very familiar with, so I can only wait and see if the author will make adjustments in the future.