Leader Following steering behavior

In this demonstration a group of ten vehicles exhibit leader following behavior. Click with your mouse anywhere in the yellow window to toggle between two modes. In one case, they are colored green and all follow the single gray leader. In the other case they are colored cyan and follow one another, forming a "single file" procession, much like a family of ducklings following their mother.

A single gray leader vehicle employs an unrelated ad hoc behavior combining seeking randomly selected locations, wandering, and selecting between fast and slow movement. It is oblivious to the other vehicles.

The leader following behavior combines separation (a desire to avoid crowding) and arrival (a desire to move towards a point, slowing as it draws near). The arrival target is a point offset slightly behind the leader. In addition, a follower will move out of the way if finds itself on the near future path of its leader. (This is more apparent in the "green mode.")

In this diagram, a vehicle's velocity vector is shown in magenta, and its steering force vector in blue. A vehicle will flash red when it touches another.


From
Steering Behaviors for Autonomous Characters