Flocking

Information
Here's a set of flocking scripts, They will follow a target, have controls for min speed, max speed, randomness.

Uses the physics engine and oversized sphere colliders to keep the boids apart.

Use the example scene in the unityPackage to figure out how to hook it all together.

Download Package
[[Media:Flocking.unityPackage.zip|Download Flocking.unityPackage.zip]]

[[Media:FlockingCS.zip|C# version]] by Benoit FOULETIER (basically just converted the original, cleaned up and optimized a bit... the logic is identical.)

JavaScript - BoidController.js
This script creates and collects information on the boids. It Uses the surface of the controller's collider as spawn points.

JavaScript - BoidFlocking.js
Each boid runs this script. It handles randomness, clumping behavior, velocity matching behavior and target following behavior.

This could be updated to include weighting factors for velocity matching, target following and clumping, as has been done for randomness.

JavaScript - BoidWatcher.js
A camera script, watches the center of the flock.

C# edition
converted by shinriyo