void Update() { if (canv.GetUpdateFlock()) { SetFlockingValues(); } for (int a = boids.Count - 1; a >= 0; --a) { Boid b = boids[a]; Vector3 velocity = b.velocity; velocity += alignment.GetAlignment(boids, a); velocity += cohesion.GetCohesion(boids, a); velocity += separation.GetSeparation(boids, a); velocity += waypoint.GoToNextWaypoint(boids, a); velocity += eatFood.GetEatFood(boids, a); velocity += flee.GetFlee(boids, a); velocity.Normalize(); b.velocity = velocity; b.lookat = b.position + velocity; } for (int i = boids.Count - 1; i >= 0; --i) { if (!boids[i].enemy) { boids[i].transform.position += boids[i].velocity * Time.deltaTime * speed; } } }