AI Steer Behavior: Pursued and Evade
- itzvnodm
- Sep 12, 2014
- 1 min read
Pursue: (Every Frame)
Calculate the distance between "Pursuer" and "Target", name it DistanceToTarget.
Use DistanceToTarget to calculate the time the Pursuer will take to reach Target, name it TimeToTarget.
Find the future position that Target will be in TimeToTarget, name it TargetPositionToPursue.
Call Seek on TargetPositionToPursue.
Evade: (Every Frame)
Calculate the distance between "Pursuer" and "Target", name it DistanceToTarget.
Use DistanceToTarget to calculate the time the Pursuer will take to reach Target, name it TimeToTarget.
Find the future position that Target will be in TimeToTarget, name it TargetPositionToPursue.
Call Flee on TargetPositionToPursue.
Seek: (Every Frame)
Calculate the Direction Vector from Pursuer to Target Position.
Calculate the Desired Velocity from the direction vector.
Calculate the Steering force "DesiredVelocityVector - CurrentVelocityVector" .
Apply the steering force on Velocity.
Calculate the new position with this velocity.
Flee: (Every Frame)
Calculate the Direction Vector from Target Position to Evader (Reverse to Seek).
Calculate the Desired Velocity from the direction vector.
Calculate the Steering force "DesiredVelocityVector - CurrentVelocityVector " .
Apply the steering force on Velocity.
Calculate the new position with this velocity.
Comentários