How to enable the Avoidance Collision Steering Behavior

The Avoidance Collision Steering Behavior steers the agent away from predicted collisions. It computes the final velocity which will move the agent from colliding with nearby agents.

The images below show how the Collision Avoidance Steering behavior is computed.

The first scenario shows two agents with Spherical Broad-Phase Boundary volumes.

The following images shows the second scenario which shows one agent wrapped with a spherical volume and the second agent wrapped with a AABB volume.

The code snippet below shows how to compute the Final Velocity using the Avoidance Collision Behavior.

//1. Create an Avoidance Collision object
U4DEngine::U4DAvoidance *avoidanceBehavior=new U4DEngine::U4DAvoidance();

//2. Compute the final velocity to steer away from any collision. The uSoldier is the agent avoiding collisions.
U4DEngine::U4DVector3n finalVelocity=avoidanceBehavior->getSteering(uSoldier->kineticAction);

//Check if the resulting velocity is set to zero. Do this as a a safeguard. I have to fix this issue.
if(!(finalVelocity==U4DEngine::U4DVector3n(0.0,0.0,0.0))){

    finalVelocity.y=0.0;

    uSoldier->applyVelocity(finalVelocity, dt);
    uSoldier->setViewDirection(finalVelocity);

}

Last updated