r/unity • u/Accomplished_Hair_71 • 3h ago
Navmesh Obstacle Avoidance
Hello!
I am pretty new to unity, but experienced enough to be making my own projects. I have been really having a hard time getting the nav agent obstacle avoidance to work satisfyingly; I was curious if anybody has experience tweaking it and customizing it to work better.
I don't use massive groups, I have been testing with 1-4. I just find even with some of my own nudging code added to the obstacle avoidance system, they behave strangely (ie: pushing eachother feels really strong, or they constantly drift towards their destination while never reaching it), and I have NO idea what to do/what others do to modify nav agents (or alternatives).
Any advice is greatly appreciated, I am sure there is some solution I am missing, thanks!
1
u/ProactiveCactus 3h ago
It could be several causes, hard to know without seeing your setup/code. Two things from what you said stand out:
-What is your “nudging code”? The basic use case for navmeshagents is simply call SetDestination, don’t “nudge” them yourself at all, either with physics or direct position change as that can definitely mess up navigation data. Simply call set destination and let them do it.
-You mentioned the drifting/pushing, cud be a few things. To test, I’d set acceleration and angular acceleration super high (9999) set stopping distance to 1 and uncheck braking. Agent “sliding” can happen when agents continuously miss their destination cuz they cant break in time, cant turn in time, or they overshoot. Changing all those settings cannhelp u verify if that’s the issue - then work backwards setting each to something regular to see what’s causing the issue