VecFlow0.1.0
FlowsOperators

Flock

Particles move together as a flock of birds or a school of fish: keeping apart, heading the same way, staying together, and turning aside from what's ahead.

VecFlow 0.1.0

Particles move together as a flock or a school: each keeps apart from the nearest few it sees, heads their way and keeps among them, cruising at its speed (with those of other events with this operator too). They turn aside from this event's Collide objects and ground before reaching them.

Add it
EventAdd OperatorPhysicsFlock
Sends on
Nothing: it has no wire.
Influence
No: a value can’t weigh it.

When to use it

Birds, fish, bats, bees, a murmuration of starlings, a shoal swerving round a rock. Each particle steers by the nearest few it can see, so a flock of fifty and one of fifty thousand behave alike.

It works across events: particles flock with those of every event with Flock.

Set it up

Birth the flock in a box or volume, with 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.

Show them as birds or fish: a Shapes collection on the Display panel, and a Rotation Along Motion with Keep Doing It and a little Bank.

Give them things to swerve round with a Collide: they turn aside before reaching its objects and ground.

BirthForcesPhysicsLooksTests

Settings

As the flow editor’s sidebar shows them. Changing any of them marks the bake old; those marked Keyframable can also change through a bake.

Cruise Speed
Keyframable
2 m/s0.001 to 30

The speed they fly or swim at.

Steering
Keyframable
10 m/s²0.001 to 100

How hard they can turn, speed up or slow down. What matters most comes first: turning aside from what is ahead, then keeping apart, then the rest.

Sight
Keyframable
1 m0.001 to 20

How far each one sees the others.

81 to 32

How many of the nearest it sees each one follows. A starling watches about seven, so a flock behaves the same however big it gets.

View
Keyframable
270°0° to 360°

How far round each one sees, ahead and to the sides. Others in the gap behind it are unseen.

Spacing
Keyframable
0.25 m0 to 5

How far apart they keep, from each other and from what they look out for.

Separation
Keyframable
10 to 3

How much each one keeps apart from others nearer than the spacing.

Alignment
Keyframable
10 to 3

How much each one heads the way the others head, at their speed.

Cohesion
Keyframable
10 to 3

How much each one keeps among the others. 0 lets a flock drift apart.

Keep Level
Keyframable
00 to 2

How much they keep level, neither climbing nor diving, as fish do.

Look Ahead
Keyframable
1 s0 to 5

How far ahead, in seconds, they look out for this event's Collide objects and ground, to turn aside before reaching them. 0 never.

How each one decides

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

  1. turning aside from the event's colliders and ground, Look Ahead seconds ahead;
  2. keeping apart from any nearer than Spacing (Separation);
  3. heading the way the others head, at their speed (Alignment);
  4. moving toward the middle of them (Cohesion), and keeping level (Keep Level);
  5. coming back to Cruise Speed.

Separation, Alignment, Cohesion and Keep Level are weights: raise one to make it count more. Cohesion 0 lets the flock drift apart; Keep Level near 1 keeps fish swimming flat.

Works with

  • Other forces add on top: a Swirl sends a school round in a ring, a negative Attract on a shark makes them flee it.
  • Rotation Along Motion, Keep Doing It and Bank, to face where they go and lean into turns.
  • An event takes one Flock, and can't also hold a Liquid, Follow Curve or Goal.

Problems you may see

Error

event: operator: an event takes only one

Errors stop a bake; warnings don’t. Every message is on the Messages page.

On this page