A* Pathfinding Project

Finding a target for each unit


#1

In my 2d rts game, I have 9 units that each have the seeker component, as well as a shared target to move towards. Is it possible that as they’re moving towards the same target, as soon one of them reaches the target, the others will simply go to some adjacent target? That way, they don’t all land on top of each other, like they do in the below example. Also, I’m using the free version of the asset. rts_example


#2

Hey,
You could use RVO to keep agents on a distance from each other.

I not familiar with the rts example. But if I’m not mistaken there is some starcraft like movement available in that demo.

See if that works for you


#3

Hi,

I already said that I’m using the free version of the asset, so I can’t use the RVO feature.


#4

Ah right, my bad sorry.

Once again you might find a few functions like this in the RTS demo.
Otherwise this is something you’d have to implement yourself


#5

Hi

Sorry for the late answer. I have been traveling and have not been able to answer support requests for some time.

Generally for keeping agents for overlapping if they are all trying to reach the same target you would use some kind of local avoidance.
However you could also order all agents to slightly different locations. Take a look at this function for example: https://arongranberg.com/astar/docs/pathutilities.html#GetPointsAroundPointWorld. This will generate a bunch of target points for your agents such that they do not overlap.


#6

Thanks. If I upgrade to the pro version, will it automatically take care of this for me? Will the pro version automatically prevent the units from overlapping once they reach their target?


#7

Sorry for the late answer.

You can use RVO and it will be able to prevent them from overlapping. However I think you will get a better result with the GetPointsAroundPointWorld method (which btw is available in the free version). This requires a bit of your own code however, it is not something that will be done automatically.