Pursuit Behavior

The Pursuit Steering Behavior is similar to the Seek Steering Behavior. However, unlike the Seek behavior, which blindly approaches a Target Position, the Pursuit Behavior predicts the future position of the Target Position.


The snippet below shows how to compute the final-predicted velocity using the Pursuit Steering Behavior.

//1. Create an instance of the Pursuit Object
U4DEngine::U4DPursuit *pursuitBehavior=new U4DEngine::U4DPursuit();

//2. Get the pointer for the evader character
Soldier *enemy=uSoldier->getEnemy();

//3. Get the predicted final velocity to approach the position of the enemy.uSoldier is an instance of your pursuer game character. enemy is an instance of your evader game character.
U4DEngine::U4DVector3n finalVelocity=pursuitBehavior->getSteering(uSoldier, enemy);

//set final y-component to zero.

//Check if the resulting velocity is set to zero. Do this as a a safeguard. I have to fix this issue.


    uSoldier->applyVelocity(finalVelocity, dt);