- Home /
Telling AI not to push each other around?
I'm messing around with the base AI scripts from the Stealth tutorial. While they all have rigidbodies, so they don't stand inside each other, they still tend to crowd up and push each other around. What is a good way to prevent this? I downloaded UnitySteer but I couldn't figure out how to use it to tell the AI to avoid each other.
Answer by Josh1231 · Aug 20, 2014 at 12:04 AM
Use Vector3.Distance and when one of them get too close they would move out of the way or change direction, you can make the bot remember the position they were going to go to and go there later if you want to, i don't actually know what UnitySteer is, so i don't know how to use it in anyway, so I can't help you with using that.
That's pretty straight forward Thinking on it, would having a Coroutine check the Vector3.distance between multiple A.I and having them move until they're no longer in range, and then yield return null work?
It should work, but if two are in range when you do this they will both stop, so you could make them all do the coroutine with different timers for example one being 0.1 and one being 0.15 so they are less likely to have it at the same time and have the script check if them being paused is enabled before pausing them.