April 13, 2008

Realtime flocking script for trueSpace7.5 based on the works of Craig Reynolds.  Flock members start in a random state and then follow a set of rules to control their motion.  Their logic tells them to react to collisions with other flock members and scene objects that have been designated as collision objects, stay close to other flock members, steer to the same heading as other flock members and steer towards the goal object.

click image to see the video(512Kb, wmv)

click any of these images to download the script
  1. choose the default aspect of the script and click the "Start" button, a goal object and the flock will be generated
  2. check the Active checkbox to start the motion
  3. click the checkbox again to freeze the motion
  4. click "Delete Flock" to delete the flock and start over

Use the "coll" aspect to choose top level objects in the scene for the flock to collide with.  "Make Flock Collision" will add the object to the simulation and "Remove Flock Collision" will remove it.

The "Asp4" aspect can be used to change the flock member template model and to set the values for the simulation.  The model that is to replace the default red "fish/bird" must have it's nose in the +Z direction and it's top in the +Y direction with all rotations set to zero.  Just select the new model and click on "new template" to use your own model.

All the rest of the attributes are the weights associated with a specific behavior and are all added together to steer the member of the flock.

Collision with objects is determined by the bounding box of the object so you can't make a box to contain the flock.  There is no obstacle avoidance behavior built in.

Craig Reynold's Boids