public void Run() { elapsed += Time.deltaTime; foreach (FlockAgent agent in agents) { List <Transform> context = GetNearbyObjects(agent); Vector3 move = behavior.CalculateMove(agent, context, this); move *= speed; if (move.sqrMagnitude > squareMaxSpeed) //reset ot max speed when exceeding { move = move.normalized * maxSpeed; } agent.Move(move); } //seperation if (elapsed > timePerSeperation) { FlockAgent agent = agents.Random(); agent.Separate(); agents.Remove(agent); elapsed = 0f; } }