Local Avoidance Query

I’ve been looking into having local avoidance follow a certain behaviour and have been having little luck. I am working on an RTS game, and whenever I order a bunch of swordsmen to attack a single unit, I would like them to avoid each other and surround the unit being attacked. The current behaviour has no local avoidance, and as a result, most swordsmen get stuck behind one another, and only two or three are able to reach the unit to attack them. Would the local avoidance in this pack allow for such surrounding behaviour out the box?

(As a reference consider the behaviour from games like Warcraft 3 where units adequately surround another and stop)

Hi

Sorry for the late answer.

This particular kind of behavior is not that well supported right now. I do have a beta version where it works better though (it uses a different algorithm inspired by what the Starcraft 2 engine does). The beta is available for download too if you want to try it (you can find it by going to the download page and clicking the ‘Show Older Versions’ button, and then downloading the one on the ‘rts’ branch).

Here’s are two videos showing some parts of it

Hi aron, thanks for the reply. I have just played around with the beta and it’s close to what I need. For some wierd reason however, a bunch of my units will stop repathing to their target’s location and just remain stationary. I assume it would not matter if I call richAI.destination = target.position; every frame?

Hi

That sounds odd. Yes, setting the destination every frame should be completely fine. Do you get anything in the log (if you enable A* Inspector -> Settings -> Path Log Mode)

Ahhh I see. Yea nothing looks too odd. Is there any way to check if it is not possible to reach the current destination? (Due to other agents blocking it)

Local avoidance doesn’t impact pathfinding, so there’s no way to know if it can reach the target or not because of other agents blocking it (for things that do affect pathfinding, you can use PathUtilities.IsPathPossible). The beta that I showed above uses some approximations to figure that out. It checks the distance to the destination (call it R), and then checks if the density of units inside a circle with radius R centered at the destination is above some threshold, and if that is the case then it stops. This is handled by the script called SC2Avoidance (or something similar) in the beta (it is attached to all characters).