NOTE: Forgot to mention this is a 2D game so I use transform.position.Vector2() a lot because a Vector3 is not needed to represent position in a 2D world.
I’ve been wrestling with this problem for a long time.
I wrote some code that successfully groups my AI around a target point, but when they get there they just vibrate constantly.
I had a code example here, but it is easier if you just see it in action.
Here is a download to the unity project:
https://drive.google.com/open?id=0B_z-b0FvwpjhbEhnYXIzb3oxbUE
The main code is in the Update function in the TestAI.cs file.
One somewhat successful attempt at removing the vibration is included.
To see it in action go to the TestAI prefab.
The child in this prefab is called Enemy, and this child contains a script called TestAISmoothing.
Enable this script to see the effect.
This method causes the AI to have delayed reactions and unwanted acceleration so I would prefer to not use it.
If you are a good programmer and you have time to take a look I would really appreciate it.
I know it is a lot to ask, but I feel this is important. I haven’t seen any other place on the forums that tackles the problem of surrounding a target.