Flock Simulator

Buy now on Asset Store!

The goal of this project was to implement behaviour of animals like fishes, birds who move in groups (flocks, schools, herds etc.) in Unity 3D.

We decided to implement concepts described by Craig Reynolds in his “Boids” project (http://www.red3d.co/cwr/boids/).

Take a look at the YouTube demonstration:


Basic Concepts

Flock members (represented by the FlockMember component) are grouped into groups (represented by the FlockGroup component). FlockGroup is a component that should be attached to a dummy game object. Each FlockMember holds a reference to its current FlockGroup.

Properties of a FlockGroup are grouped into four categories that represent steering behaviour of the flock. They are

  • alignment: steer towards the average heading of local flockmates,
  • separation: steer to avoid crowding local flockmates,
  • cohesion: steer to move toward the average position of local flockmates,
  • random: steer randomly.

Tweaking FlockGroup properties can change behaviour of its members entirely. It is recommended to choose the parameters experimentally.

The FlockGroup fills its FlockMembers’ public flockOutput fields that represent where each flock member would like to go according to its herd instinct.

Please note that FlockSimulator components don’t actually move any objects, just express the desire of every flock member to go in a given direction. It’s up to the programmer to use flockOutput to obtain the result that is expected. Wedecided to make it that way to ensure flexibility.