force.flocking

Separation, alignment and cohesion for a flock, with live weights and radii.

force.flocking(layout: SteeringLayout, cfg: {maxAgents: number}): AgentSteer2

Import sim from shaders/std and use sim.agentForces.force.flocking.

Parameters

NameTypeNotes
layoutSteeringLayout
cfg{maxAgents: number}

Example

forces: [force.flocking(simLayout, {maxAgents: 4096}), force.cursorSteer(simLayout), force.wallTurn(simLayout)]

See also

  • force.cursorSteer — The cursor on a flock: attract, scatter like a predator, or nothing.
  • force.wallTurn — A soft turn back toward the canvas near an edge, so a flock arcs instead of bouncing.
  • integrator.steering2d — A flock under summed steering, kept cruising, arcing off the canvas edges.