Flock simulation Unity

Flock simulation
This week we tried to use Unity for something different – a little flock simulation.

We implemented simple BOID algorithm to simulate behavior of Animals flocking.
BOID algorithm consists of three simple steering behaviors:

SEPARATION – steer to avoid crowding local flock-mates
ALIGNMENT – steer towards the average heading of local flock-mates
COHESION – steer to move toward the average position of local flock-mates

separation
Separation
alignment
Alignment
cohesion
Cohesion

Image source: http://www.red3d.com/cwr/boids/

Each agent in simulation is GameObject with BoidAgent scripts attached to it. Script has some public parameters for tweaking and testing different parameters.

You can download our implementation with demo scene here.

Hope this helps somehow! 🙂 If you have any questions don’t hesitate to ask in comments!