This entry is part of 9 in the series Steering Behaviors

Time for the next steering behavior, fleeing. This will use the same Vehicle.as class and will be built off what we did in the seeking behavior. It is based on Craig Reynolds’ article, Steering Behaviors For Autonomous Characters.

Fleeing Behavior

Fleeing is very similar to seeking. It is actually the inverse of seeking. Instead of going towards the target, fleeing goes away from the target. It works like this:

1. desiredVelocity = target – position

2. desiredVelocity is normalized and multiplied by maxSpeed.

3. desiredVelocity is multiplied by -1 to go away from the target

4. steeringForce More >