How to solve this collision of units in corners?

  • A* version: lastest
  • Unity version: 6000.3.9f

Hi, please, here is way to solver this behaviour? so much players are reporting that when the units wants to walks near to obstacles or something like that, they pulls and slow agains the obstacle corner

Then, is possible some configuration where the paths avoid a little bit the corner of the obstacle?

This happens in StarCraft 2 in a right way

Thanks so much!

I was able to get some less clumpy results by playing with the wall distance setting on FollowerEntity. If you want a particular result though, I don’t think there’s any “stay clean around corners” setting just built it- you’d have to build it. If you have any questions about what options you have to code it yourself I can provide some pointers.

1 Like

Please help me with that pointers, also I want know if recast graph give me betters results in this situation, because all my project is in grapgrid

Thanks so much @tealtxgr

If you’re not using FollowerEntity you can use a Modifier, for starters. There is a built-in modifier for this, the Radius modifier. The idea is that when your units begin rounding a corner, you dynamically can give all your units a different radius, maybe based on their index in a list? The hard part of this would be “detecting corners” but you could always just check your current path and get the direction from currentNode to nextNode (these are not built into Astar, they’re just example names) and then also get the direction from nextNode to nextNextNode. If the angle of those two directions is more than, say, 60f, a corner is then detected, and you can change their Radius modifiers. This modifier is prone to issues here and there, however. This is not a silver bullet!

If you are using FollowerEntity, you’d probably want to get the remaining path and then modify the path itself in a similar way-- pushing the next point further from a wall on a detected corner, then reapplying the Path to the agent.

Another novel solution would be to just use tags/penalties since you’re using a grid graph especially. This would be as simple as getting the node nearest the unit when they’re rounding a corner and add a tiny bit of penalty to it, then when they leave that corner node, remove the penalty. You’d have to be careful with this one as, depending on your situation, they may try and go some other way altogether.

If you want you can also do a lot of custom movement script making, which is usually my personal preferred way of using Astar since I like to keep granular control of how my agents move.

The FollowerEntity actually has code for doing exactly this. When using local avoidance, it will dynamically increase/decrease its desired wall distance based on how large of a group it is moving in.

This should work the same in recast and grid graphs. Though recast graphs tend to be a bit better for fluid movement in general.