Many Agents That Won't Overlap. Local Avoidance?

Hello, I am fairly new to Unity and I have been messing around with this pathfinding project in 2d. I have been trying to have multiple agents that can move toward a target and not overlap each other. I tried to add rigidbodies to the agents but it did not seem to work. I was reading about the local avoidance, although it seems rather complex. Is this the kind of thing I need for what I want to do? I saw that it is included in the pro version however once I saw that it costs $100 that no longer became an option for me since this is more of a hobby right now and that’s rather expensive for just wanting that feature.

So I guess I want to know is there a simple way to get many agents to use pathfinding but at the same time not overlap each other without completely bugging out and shoving each other through walls or anything like that? I wanted to play around with a kind of 2d battle simulator that uses pathfinding in case there are walls and such in the scene. I thought this might be simple but I am having a hard time finding a solution and perhaps it is more complex than I thought.

Thanks in advance for any help!


Physics sort of works, but usually it is better with some smoother anti-penetration force. So if two units get to close, push them away from each other. This will get you decent behavior in many cases.

You can also enable the ‘constrainInsideGraph’ option on the AIPath script to make sure it does not get pushed outside the graph.

I suppose that makes the most sense. What script should I be altering? The AILerp.cs? So far trying to add force to an object that is using the pathfinder does nothing. I am not sure if something is be overwritten somewhere or where I should be looking to add force.


The AILerp script is intended for agents that follow the path exactly, never deviating at all. It will not work well with any kind of local avoidance. Try the AIPath script instead.