VecFlow0.1.0
Effects guides

Flocks and schools

Birds, fish and swarms that steer together: Flock's settings one by one, swerving round obstacles, keeping level, and shapes that face where they go.

VecFlow 0.1.0

A flock is many particles each steering by the few nearest it can see: keep apart, head the same way, stay together. Nobody leads, and the flock's shape comes from that alone, much as starlings and fish do it.

Start from

The Swarm starter is a flock of paper darts following a leader. Or start from the Particles starter and press Convert to Flow, or a new empty flow: a flock needs only a few operators.

The flow

A school of fish: born in a volume, steering by Flock, turned to face where they swim, swerving round the rocks.BirthForcesPhysicsLooksTests

Birth them All at Once in a Position Volume, the space the flock starts in. A little Speed and Spread, so they don't all start the same way.

Add Flock. Set Cruise Speed to how fast they go, and Spacing to how far apart they keep.

In the Display panel, set Shapes to a collection holding the bird or fish, modelled pointing along one axis.

Add a Rotation Along Motion, with that Axis, Keep Doing It on and a little Bank: they face where they go and lean into their turns.

Add a Collide with what they should swerve round: they turn aside before they reach it.

Flock's settings, one by one

Each particle sees the nearest Follow others within Sight, in front of it within View, and steers as hard as Steering allows, the most urgent first:

SettingWhat it doesTry
Cruise SpeedThe speed they come back toBirds 5 to 10 m/s, fish 1 to 2
SteeringHow hard they can turn and change speed. Low swings in wide arcs; high darts5 to 20 m/s²
SightHow far each sees the othersA few times Spacing
FollowHow many of the nearest it follows. A starling watches about seven, so a flock acts the same however big6 to 10
ViewHow far round it sees; others in the gap behind it are unseen270°
SpacingHow far apart they keep, and from what they look out forA body length or two
SeparationHow much they keep apart1; more for loose swarms
AlignmentHow much they head the way the others head1; more for orderly schools
CohesionHow much they keep among the others. 0 lets the flock drift apart1; more for tight balls
Keep LevelHow much they keep level, neither climbing nor diving0 for birds, near 1 for fish
Look AheadHow far ahead, in seconds, they look out for colliders and the ground1 s; more for fast flocks

Shaping the flock

The flock wanders by itself. To steer it as a whole, add forces to the event; Flock adds its steering on top:

  • a Swirl round an object sends a school circling in a ring, a bait ball;
  • an Attract toward a moving empty leads the flock along, as if it were following food;
  • a negative Attract on a predator, with a Reach, makes them scatter from it and close up again behind.

What goes wrong

  • They clump into a tight ball. Separation too low, or Spacing too small for their size.
  • They fly through an obstacle. Look Ahead too short for their speed, or the obstacle isn't in this event's Collide.
  • The shapes fly sideways. The Rotation's Axis isn't the one the model points along. Check it in the shape's own object, unrotated.
  • Fish pitch up and down. Raise Keep Level.
  • They jitter. Steering too high with a small Spacing: they correct too hard. Lower Steering, or raise Spacing.

On this page