Implementing steering behaviors
The strategies that we will cover here have been taken from Craig Reynolds's paper Steering Behaviors for Autonomous Characters, written in 1999. It has become a well-known reference for implementing autonomous motion in an easy manner for non-playable characters.
You can check out the online version at http://www.red3d.com/cwr/steer/gdc99/. In this section, you will learn how to implement the following kinds of behavior:
- Seek and flee
- Arrival
- Pursuit and evade
- Wander
- Obstacle avoidance
Seek and flee
The seek behavior moves the character towards a specific position in the space. This behavior is based on the combination of two forces: the character's velocity and the steering force. This force is calculated as the difference between the desired velocity (the direction from the character to the target) and the character's current velocity.
Note that this is not a force in the strict physics definition; it is just another velocity vector. You can think...