Hello! I've made a simple AI Script,which is based on a NavMeshAgent,which works perfectly but It has 1 issue. When I will create 10 NPC's with my script,and when I will give them 1 Target - a player for example. They are pushing eachother but I want them to avoid their "brothers" I tried to do something with localAvoidance Property but It doesn't work for me (I see no difference). How can I solve this ?
After two years you still can't solve this stupid problem. Blame you Unity !!! Who figured this out that agents should behave like this at the first place ?! No avoidance just pushing ? Give me a break. It's not a crowd behavior. Workaround: - put some bigger colliders on each agent (with some separate layer) - in physics setting set that they collide only each other - on trigger enter agent with f.g. lower ID (those build-in priority is only from 0-99) so use your own variable - stop agent - disable navmeshagent - enable navmeshobstacle (in this order) - on trigger exit - disable navmeshobstacle - enable navmeshagent (in this order) - continue with moving a navmeshagent Still super unnatural when one person is stopping but better this than pushing. Other option is make quick temp destination (depends of collision angle) onCollisionEnter - save main destination set new tem destinations to avoid each other onTriggerexit - set back main destinations
I love Unity! But the navigation system is just terrible. I still can't believe it. It is not updated with the same frequency as/together with physics, which is a major issue in my opinion. I mean I get it, they want to make sure that physics primarily will always run stable (I guess?). But then... why not add the update frequency to the project settings? Stable and full physics interactions with vehicles for example are a must in my opinion. Then, as you said, the local avoidance is simple and bad. I mean... what the hell Unity. As mentioned here, Jakob is missing. He was the only man truly helping here. Now he's gone and us, poor defenseless devs remain here... sad and desperate in these dark times. Is there anyone left to save us?
Is there still no way to properly work around this besides using something else than unity's navmesh ? Would using A* solve this issue ? My problem is that I have a crowd (up to 1000 units or so), the behaviour looks good until I reach something like 150 units following the same destination point and they all just push themselves away and it looks ridiculous. I have tried many things to solve this but nothing has worked yet. I'll try tomorrow what @TomPo said but it looks pretty unnatural and I'd like to avoid such fix !
This thread is old but my answer might help someone. Here it is what helped me, try playing with Nav Mesh Agent "Obstacle avoidance". What you described happens when both objects have their "priority" set to same number. Try assigning different numbers to your characters or try disabling it for some, it will solve the issue of them pushing each other. Now which character should have higher priority is up to you.
Your issue has to do with the AI's stopping distance/attacking distance, thats why they push you around. Stop blaming Unity.
thats unity fault. if you write own script that will cutout part of mesh then if will avoid and make path. othervise it will bump or start to walk very slow
Ok here it is. With basic avoidance you cant surround other agent like in game Warcraft3 because they will crowd and push eachother. When agent not able to push other -> surrounded unit wont be able to escape in this case. This package on github solves problem but not 100% https://github.com/jadvrodrigues/CustomNavMesh
May not be 100% but looks workable, dont think ive seen that GitHub package before, but then again ive never had this problem in my games. I just know that stopping distance/attacking distance is the cause of the pushing problem. Good to know about this package, who knows what the future holds, could be very useful in certain senerios