Closest RichAI to the player

Hi,

I have several RichAI agents wandering on navmesh, where only the closest one (closest path) should walk towards player.

I know that I can use ABPath.Construct to calculate path for each seeker to the player, but how can I compare which is the shortest path between all those seekers?

I could maybe cheat and put seeker on a player and do StartMultiTargetPath and then get closest AI so I engage that one, but it’s not that “clean” solution I’m looking for :slight_smile:

Thanks

Hi

Do you need the closest one in terms of navmesh distance? Or is just the closest one as the crow flies good enough?

Hi Aron,

I need the one where closest agent mean he will get fastest to the player.
So if there’s agent closest to the player in Vector3.Distance, but there’s an object in between so agent needs to go around, and in that case some other agent would reach player faster, I need to find that agent which would reach player faster than others :slight_smile:

Of course all agents are the same (speed, etc.)

Thanks!

Hey you could use the multi target path for this:
https://arongranberg.com/astar/docs/class_pathfinding_1_1_multi_target_path.php

Startin from the player to the ai agents. Then find the shortest path.

Thanks, was wondering if there’s another way to do it only once.
If I do this, I’ll have to, when I find shortest ask agent, to calculate again from agent’s position if I understand correctly.