Arrive Behavior

The Arrive Steering Behavior behaves the same as the Seek Steering Behavior. The only difference is that the agent reduces its speed as it approaches the target position.


You can set the radius distance to the target the agent should come to a stop by using the following method:

void setTargetRadius(float uTargetRadius)

You can also set the radius distance to the target where the agent should start slowing down by using the following method:

void setSlowRadius(float uSlowRadius)

The snippet below shows how to compute the Arrive Steering velocity.

//1. Create Arrive Behavior instance
U4DEngine::U4DArrive *arriveBehavior=new U4DEngine::U4DArrive();

//2. set distance to come to a stop

//3. set distance to start slowing down

//4. Set target position to arrive
U4DEngine::U4DVector3n targetPosition=U4DEngine::U4DVector3n(2.0,0.0,3.0);

//5. Compute the final "arrive" velocity for the character. uSoldier is an instance of your game character.
U4DEngine::U4DVector3n finalVelocity=arriveBehavior->getSteering(uSoldier, targetPosition);

//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);