Flocking System Breakdown

Flocking Systems | Boids | Geometric Flight | Flocking Behaviour | Collision Avoidance | Velocity Matching | Flock Centring | Examples | Steering Behaviours | Seek and Flee | Pursuit and Evasion | Arrival | Wander | Path Following | Wall Following and Containment

Seek and Flee

Seek acts to steer the character towards a specified target. It is the most basic of all boid behaviours as it simply requires a target position in global space to be passed to the simple vehicle model, in order to generate the desired steering vector.

In order to adjust the boid so that its velocity is aligned towards the target, it generates a desired velocity vector, which is the velocity the boid would have if physical constraints did not apply. The steering vector is obtained by calculating the difference between this desired velocity and the boid’s current velocity. The following pseudo code demonstrates this simple algorithm:


desired_velocity = normalise(position - target) * max_speed;
steering_vector = desired_velocity – velocity;


If a boid continues to seek, it will eventually pass through the target, and then turn back to approach again. Therefore, another technique called arrival should be used as the boid gets nearer to the target.


Flee

Flee is the exact opposite of seek, in that it acts to steer a boid away from the given target. The inverted vector is derived from the above equations.

 

 

 

 

<< previous | next >>