How to use StartMultiTargetPath with multiple starts to same end


I’ve seen that StartMultiTargetPath has an overload where you can have multiple start points that search a path to one endpoint.

I want to have several enemies (that get spawned during runtime) that should chase the player.

At the moment, each enemy has its own

  • AIDestinationSetter
  • Seeker
  • AIPath

So, I think that using StartMultiTargetPath seems a good idea in my case.

However, I am unsure about how to use it correctly.

I thought I would only use one seeker at a root GameObject and hand over the paths to the AI, but each AIPath requires a Seeker component.

So, I am unsure how to use it for multiple enemies targeting one moving endpoint.

Can someone give me some hints?


While it is possible to use a single MultiTargetPath from the player to calculate a path to all following agents, I would first ask you if doing it the normal way is not completely fine from a performance standpoint? Do you have several hundred characters (or thousands) all converging on the same point?

1 Like

Hi @aron_granberg

I am not that far yet in development, but it will be for mobile, so when I can squeeze out some performance, I want to do it. :slight_smile:

I am not sure how many enemies will be walking simultaneously because I need to test it with some mobile devices and what they can handle.

At the moment its my own curiosity.

While it is possible to use a single MultiTargetPath from the player to calculate a path to all following agents

It’s the other way around: Multiple agents to one player. That’s why I was thinking that using StartMultiTargetPath with multiple start points to one endpoint may fit.

Premature optimization is the root of all evil.

It is possible to do what you want, but it requires a bunch of code. I would strongly recommend waiting until you see that pathfinding is actually a performance issue. Something I doubt will happen unless you have many hundreds of units calculating paths all the time.

If you want to do it, this is the probably the way to go: FloodPath - A* Pathfinding Project

That’s true, yes. :slight_smile:

Thanks for pointing me to the FloodPath. At least I will have some starting point when I recognize issues with the path-finding performance.

Thanks @aron_granberg!