# Physics: Boids

Image 4: Physics panel for Boids particle.

Boids particle systems can be set to follow basic rules and behaviors. They are useful for simulating flocks, swarms, herds and schools of various kind of animals, insects and fishes. They can react on the presence of other objects and on the members of their own system. Boids can handle only a certain amount of information, therefore the sequence of the Behaviour settings is very important. In certain situations only the first three parameter are evaluated.

Boids try to avoid objects with activated Deflection. They try to reach objects with positive Spherical fields, and fly from objects with negative Spherical fields. The objects have to share one common layer to have effect. It is not necessary to render this common layer, so you may use invisible influences.

## Behaviour

• Only a certain amount of information can be evaluated. If the memory capacity is exceeded, the remaining rules are ignored.
• The rules are parsed from top-list to bottom-list (thus giving explicit priorities), and the exact order can be modified using the little arrows in front of each row. The list of rules available are:
• Collision: Avoid objects with activated Deflection.
• Avoid: Avoid “predators” (objects with Spherical fields and negative Strength).
• Crowd: Avoid other boids.
• Center: Get to flock center.
• AvVel: Maintain average velocity.
• Velocity: Match velocity of nearby boids.
• Goal: Seek goal (objects with Spherical fields and positive Strength).
• Level: Keep the Z level. The boids then try to not change their flightlevel. This is deactivated for 2D boids.

Each rule can be individually weighted; the value should be considered how hard the boid will try to respect a given rule (a value of 1.000 means the Boid will always stick to it, a value of 0.000 means it will never). If the boid meets more than one conflicting condition at the same time, it will try to fulfill all the rules according to the respective weight of each. Any rule could be weighted from -1.000 to +2.000 in order to give it more or less significance.

• Normal behavior can be expected with weights between 0.000 to 1.000.
• From 1.000 to 2.000 the boids over react according to the rules.
• From -1.000 to 0.000 the boids react contrary to the rules.

Please note that a given boid will try as much as it can to comply to each of the rules he is given, but it is more than likely that some rule will take precedence on other in some cases. For example, in order to avoid a predator, a boid could probably “forget” about Collision, Crowd and Center rules, meaning that “while panicked” it could well run into obstacles, for example, even if instructed not to, most of the time.

As a final note, the Collision algorithm is still not perfect and in research progress, so you can expect wrong behaviors at some occasion. It is worked on.

## Physics

Image 5: Boids particle are able to follow a curved surface.
• MaxVelocity: Maximum velocity.
• AvVelocity: The usual speed percent of max velocity. If MaxVelocity is set to 10.000 and AvVelocity to 0.300, then the average velocity of the boids is 3.000.
• LatAcc: Lateral acceleration percent of max velocity (turn). Defines how fast a boid is able to change direction.
• TanAcc: Tangential acceleration percent of max velocity (forward). Defines how much the boid can suddenly accelerate in order to fulfill a rule.
• Banking: Banking of boids on turns (1.0 == natural banking).
• MaxBank: How much a boid can bank at a single step.
• N: How many neighbours to consider for each boid.
• 2D: Constrains boid to a surface: either to the surface of a given object (if specified in the OB field) or to a certain Z value (GroundZ). Useful to simulate herds on a ground, for example. When activated, Level, Banking and MaxBank become irrelevant.
• GroundZ: Default Z value.
• OB: Object’s surface the boid is constrained to.
• If boids trajectory leads them out of the surface of an object, the GroundZ value is then used. E.g. Boids will distribute on the top half of a sphere and then “drip” to the ground.

## Boids, deflectors and effectors

As mentioned before, very much like Newtonian particles, Boids will react to the surrounding deflectors and fields, according to the needs of the animator:

• Deflection: Boids will try to avoid deflector objects according to the Collision rule’s weight. It works best for convex surfaces (some work needed for concave surfaces).

For boid physics, Spherical fields define the way the objects having the field are seen by others. So a negative Spherical field (on an object or a particle system) will be a predator to all other boids particle systems, and a positive field will be a goal to all other boids particle systems.

When you select an object with a particle system set on, you have in the Fields tab a little menu stating if the field should apply to the emitter object or to the particle system. You have to select the particle system name if you want prey particles to flew away from predator particles.

• Spherical fields: These effectors could be predators (negative Strength) that boids try to avoid or targets (positive Strength) that boids try to reach according to the (respectively) Avoid and Goal rules’ weights. Spherical’s effective Strength is multiplied by the actual relevant weight (e.g. if either Strength or Goal is null, then a flock of boids won’t track a positive Spherical field).

You can also activate Die on hit (Extras panel) so that a prey particle simply disappears when “attacked” by a predator particle which reaches it. To make this work, the predator particles have to have a spherical field with negative force, it is not sufficient just to set a positive goal for the prey particles (but you may set the predators force strength to -0.01). The size of the predators and the prey can be set with the Size button in the Extras panel.