Support Forum

Set seeker destination to adjacent node; Stop Agents from overlapping

I have the free version of this product. My game is top down on a 4 directional square grid. It occurs in real time. I am using AILerp for my movement. I have 2 agents (A and B). The behavior I want is that when the agents see each other, they will move to the other’s position and wait. I also don’t want them to overlap or be able to move through the other, so they should move to the adjacent square.

I have tried a lot of things and nothing seems to work.

  • I have gotten both agents to chase each other properly, but there is a lot of buggy movement. The agents will sometimes move over each other several times before finally stopping over each other.
  • Since the destination is always on top of the other agent, I tried just getting rid of the last couple way points so that it ends up adjacent to the other agent doing something like this:
void GetPath(Path p) {
        ai.destination = p.vectorPath[p.vectorPath.Count - 2];
  • I tried making two different grid graphs for each type of agent. In each graph I add the other agent as an obstacle layer so that they get avoided, but this still causes overlap. Maybe I have to constantly update after each square movement?

What would be the best way to do this? I think my main problem is that both of the agents are constantly moving so the path needs to constantly update making the stopping point unpredictable. I’m not even sure I’m asking the right questions. Any thoughts on how I should approach this?