Wander Behavior

The Wander Steering Behavior creates the illusion that the agent is randomly walking around the game scene.


You can set the distance offset between the agent and the Wander target using the method below:

void setWanderOffset(float uWanderOffset)

You can also set the wander circle radius using the method below:

void setWanderRadius(float uWanderRadius)

And you can also set the rate at which the agent computes a new random velocity.

void setWanderRate(float uWanderRate)

The snippet below shows how to compute the final velocity using the Wander Steering Behavior.

//1. Create an instance of the Wander Steering Behavior
U4DEngine::U4DWander *wanderBehavior=new U4DEngine::U4DWander();

//2. Set the Wander Offset

//3. Set the Wander Radius

//4. Set the Wander Rate

//set wandering position
U4DEngine::U4DVector3n targetPosition;

//5. Compute the final Velocity using the Wander Steering Behavior. uSoldier is an instance of your game character.
U4DEngine::U4DVector3n finalVelocity=wanderBehavior->getSteering(uSoldier, targetPosition);

    uSoldier->applyVelocity(finalVelocity, dt);