# AI: Organized attacks

Hi,

I am working on a sword game and having troubles with planning organized attacks.

Take a look this video captured from Assasins Creed. I want to achieve this kind of AI behaviour when multiple enemies need to attack one-single player.

I can not locate my enemies around my player. I have tried to calculate preferred-positions for enemies around the player, but somehow it didn’t look good.

Can you forward me to helpful articles or explain the behaviour i should implement to my enemy units?

I am going to assume you have the enemies in a list called "enemies". Then this should bring you forward:

``````    int rad = 30;
for (int i=0; i<enemies.Count;i++) {

//summon the enemies around this central GameObject
float radian = i * Mathf.PI/(enemies.Count/ 2);
Vector3 ePosition = new Vector3(rad * Mathf.Cos(radian),transform.position.y , rad * Mathf.Sin(radian) );
enemies*.position = ePosition;*
*}*
*```*
*<p>Put this in a script on the player you want to surround. If it does not work, pls report back and show a screenshot of what you got. You could put in the Update() or in a function which is called when the main player moves. Also you'd probably want to replace the last line of code with something like this:</p>*
*```*
_enemies*.walkTo(ePosition);*_
_*```*_
_*<p>So much for the positioning. To attack one at a time simply create an object that is designated to be filled by an enemy and designate it to a random enemy if it is empty. Set it to "null" again, if this particular enemy died and make it so that it designates another random enemy again to be the "acting" one. Let the acting one act, and the others rest :)</p>*_``````

As promised, here is the video. I have implemented @timsk’s idea. seperation vector still needs some work but.