Steering Behavior: Fleeing
- Steering Behaviors: Wander
- Steering Behaviors: Pursuit and Evade
- Steering Behavior: Fleeing
- Steering Behaviors: Seeking
- Steering Behaviors: Arrival
- Steering Behaviors: Obstacle Avoidance
- Steering Behaviors: Unaligned Collision Avoidance
- Steering Behaviors: Flow Field Following
- Steering Behaviors: Path Following
- Steering Behaviors: Flocking
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 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 = desiredVelocity – velocity
5. update the vehicle.
In code, it looks like this:
var desiredVelocity:Vector2D = target.subtract(position).normalize().multiply(maxSpeed); var steeringForce:Vector2D = desiredVelocity.subtract(velocity); velocity.add(steeringForce.divide(mass).multiply(-1));
Click here to see fleeing in action!
After we finish these basic behaviors, the fun behaviors get to come out!
| Print article | This entry was posted by rocketman on June 12, 2010 at 11:00 AM, and is filed under AI, AS3, Steering. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |








