I’m currently working on a top-down scene where there a bunch of characters of the same type, each with a
NavigationAgent2D. In that scene, there are also static objects that get incorporated into the
NavigationRegion2D. These agents have destinations they’re bound for, which change over time, and sometimes they’re supposed to be standing still.
What I want to make happen is for agents that aren’t moving to stay put, and have other moving agents go around them. Think like a person standing on the street, someone walking would navigate around them.
What happens by default depends on my avoidance settings. In this case, I have a stander and a walker.
If I have avoidance enabled on both, the stander moves away from the oncoming walker as the walker approaches.
If I have avoidance disabled on the stander, the walker just attempts to walk straight through the stander, which fails in this case.
The solution that comes to mind is that perhaps I can convert my stander into a different state such that I turn off avoidance and rebake the navigation mesh perhaps? This feels really inefficient, but is the only way I’ve thought of as of yet. I also haven’t tried this, but conceptually seems like it should work.
So my question is, is that the intended way to do this kind of thing, or have I missed something in the documentation? If I understand what I’m reading, avoidance isn’t supposed to affect pathfinding, nor are obstacles.
Not to be prematurely optimizing anything, but if a rebake of my navigation region is required (which currently comes from a tilemap, if it’s relevant), I have concerns about performance. I eventually want a lot of these agents in a scene at once, and any arbitrary number of them standing and walking in possibly constrained areas.
Edit: After some more experimentation, is this what
NavigationObstacle2D is for? It feels like it’s kind of acting roughly the way I want, kinda-sorta sometimes? I’m still messing with it, but it does seem to have an avoidance impact, but not necessarily on the path itself, and not consistently, which is odd to me.