Multiple Agents - Use Same Path?

Couldn’t find this elsewhere so I apologize if I just missed other topics.

I would like a way to make multiple controllers follow the same path. What’s happening now is, I have a unit of 4 and I tell them to go to a spot. If because of relative path length some of the controllers take a different path the unit will split up. That is highly undesirable in my case. I’ve tried having all members follow the closest member, but that looks janky.

So, is there a suggested way to have multiple controllers follow the same path as a leader controller? This is using a path node graph.

If you have A* Pro you can use MultiTargetPath (multiple actor to one target) , set heuristicMode to Sequential , all your actors will move to shortest node point then they will follow the same path, I haven’t seen any function at free edition about that.

Thank you! That is exactly what I needed.

Ok, I’m finally getting back to implementing this. I understand how to request a MultiTargetPath result using seeker.StartMultiTargetPath. I have multiple agents using multiple start points and one end target point.

What I don’t understand is the following:

  • Should I only call this once for a group of agents? If so, how should I process the MultiTargetPath result when the result is returned to OnPathComplete?
  • If I call it once for every agent, aren’t I just determining multiple paths multiple times?

I’ve looked over the example shown here:
http://arongranberg.com/astar/docs/_multi_target_path_example_8cs-example.php
But all I see it doing there is drawing the resulting paths once it gets to OnPathComplete.

Any help is greatly appreciated.

Hi

Multi target paths are not really the tool for this job.
It’s hard to say exactly how you should continue because I do not know the specifics of the game, but here is one suggestion.

A good way to do it I think would be to plan a single path for the whole group at regular intervals, and then for the individual units, you request a path to a point some distance ahead along that path.
See the attached image.

Just by way of followup, I went back and redid this using your suggestion Aron.

What ended up working was:

  • Getting paths to the new target.
  • Determining the agent with the shortest path length. That agent keeps its target.
  • All other agents in the unit uses that shortest paths nodes as a set of sequential targets.
  • As an agent got close enough to a target node on the path, it would pick another node further on in the path.
  • Until the lead agent was close enough to it’s goal to set a final target position for all members of the unit.

Thanks all.

1 Like

I guess, flowfield-based navigation and dijkstra algorithm are more suitable for this purpose.

http://forum.unity3d.com/threads/pathfinder-reinventing-the-wheel.367941/

Do not take for advertising, it’s not even alpha-version. There is still plenty of work.

@Andrew_Algin not really. Even flow fields or dijkstra will not guarantee that they pass on the same side of an obstacle. The final result will be approximately the same as if A* had been used.