Prototype/Source/Prototype/Private/Task_MoveToWP.cpp
/* Moves toward the neighbor closest to the waypoint (chance-based).
*/
Moves toward the neighbor closest to the waypoint (chance-based).
Moves toward the neighbor closest to the waypoint ( chance - based ) .
void AUSARAgent::FollowBestNeighbor()
{
    distToWP = FVector::DistXY(GetActorLocation(), flockWPs[0]);
    if (FMath::FRand() < CHANCE_FOLLOW) {
        AUSARAgent* agentToFollow = this;
        for (AUSARAgent* n : neighborAgents) {
            if (n->distToWP < agentToFollow->distToWP) {
                agentToFollow = n;
            }
        }
        flockWPVector += agentToFollow->GetActorLocation() - GetActorLocation();
    }
}
void AUSARAgent :: FollowBestNeighbor ( ) { distToWP = FVector :: DistXY ( GetActorLocation ( ) , flockWPs [ 0 ] ) ; if ( FMath :: FRand ( ) < CHANCE_FOLLOW ) { AUSARAgent * agentToFollow = this ; for ( AUSARAgent * n : neighborAgents ) { if ( n -> distToWP < agentToFollow -> distToWP ) { agentToFollow = n ; } } flockWPVector += agentToFollow -> GetActorLocation ( ) - GetActorLocation ( ) ; } }
Moves toward the neighbor closest to the waypoint (chance-based).
Moves toward the neighbor closest to the waypoint ( chance - based ) .