The Navigation Behavior class computes the optimal path computed from a Navigation Mesh using the A* algorithm. It then returns a Final Velocity which steers the agent along the computed path.
The Navigation Behavior class, U4DEngine::U4DNavigation requires a Navigation Data in order to compute the path and steering velocity.
The code snippet below shows how to use the U4DNavigation class:
//1. Create a Navigation ObjectU4DEngine::U4DNavigation *navigation=new U4DEngine::U4DNavigation();//2. Load a Navigation Mesh by providing the name of the nav mesh and the fileif(navigation->loadNavMesh("NavmeshName","navMesh.u4d")){ //set options here such as path radius}//3. Compute Optimal Path. The method required a pointer to the agent dynamic action and a Target Position.navigation->computePath(myCharacter->kineticAction,targetPosition);//4. Compute the final "Navigation" velocity for the characterU4DEngine::U4DVector3n finalVelocity=navigation->getSteering(myCharacter->kineticAction);//Set the final velocity y component to zero.finalVelocity.y=0.0;//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))){uSoldier->applyVelocity(finalVelocity, dt);uSoldier->setViewDirection(finalVelocity);}