- Home /
NavMeshAgents bumping into stationary agents
Let's say I have several navAgents in my scene and some of them are moving towards their destinations and some are standing still. Now the problem is that the moving agents are bumping into agents that are standing still. What would you suggest to prevent this?
Answer by HazeTI · Apr 03, 2012 at 11:25 AM
You will need to implement some form of AI avoidance. There are many different ways of doing this, some more complex than others.
Some use steering to actually change the path the AI takes.
A more simple method is to just using force repulsion to "push" agents away from each other.
Try searching for "AI avoidance" both on the Unity Forum & Unity Answers and also in Google.
Could you explain in a bit more detail what do you mean by "force repulsion"?
Sure, effectively what that means is that we check each character in turn and see if they are too close to each other.
If they are then we slightly modify their movement direction away from that character.
The amount we modify is directly linked to how close they are.
Think of two magnets and how the more you try to bring them together the more the push each other apart.
Doing a search for "repulsion steering" on Google came up with this book snippet which should prove useful, it also contains some pseudo-code.
Hope that helps.
Thanks, it helps, but it doesn't seem that simple in my case (we are dealing with moving agents bumping into STATIONARY agents; moving agents don't bump into other moving agents). It's not just deciding when to turn but also you need code to wisely decide which direction to turn - if chosen incorrectly, the length of the path might increase a lot or you might even get stuck. It's as if you need another pathfinding on top of unity's implementation. BTW, UnitySteer seems to have implemented similar behavior to the one described in the book you suggested.
Hmm, I did create quite a long post but then I thought I'd look into UnitySteer before I posted and it does looks like UnitySteer does do everything you want it to, can you not use that?
Yeah, after reading a bit more about it and checking out the demo project, it really does seem to be what I am looking for. Thanks for pointing me the right direction :)
Your answer
Follow this Question
Related Questions
CalculatePath often returns wrong results 0 Answers
Navmesh with destructible obstacles 1 Answer
Increase size of obstacle - navmesh 1 Answer
Connecting two navmeshes without "Speedboost" 0 Answers
NavMeshAgent Not Accounting for Objects 0 Answers