Seek and Flee steering behaviors

In this demonstration, the green vehicle seeks the target at the center of the window while the red vehicle flees from it. The two vehicles are initialized with identical random position and velocities. When the green vehicle gets close to the target (indicated by a color change in the target symbol) the demonstration is restarted. The velocity of each vehicle is indicated by a magenta vector, and the steering force is indicated by a blue vector.

Seek attempts to steer a vehicle so that it moves toward the goal. This is in contrast to a central force (such as gravity) which causes an inward acceleration and so leads to orbital motion. Seek and flee apply a steering force in the direction which is the difference between the current velocity and the desired velocity (towards the target for seek, away from the target for flee).

Steering Behaviors for Autonomous Characters