Prototype/Source/Prototype/Private/Task_ObstAvoid.cpp
/* Check area around vector. Returns true only if all vector checks found to be clear.
*
*   @param vector The vector to check.
*   @return True if area around vector found clear.
*/
Check area around vector. Returns true only if all vector checks found to be clear.
Check area around vector . Returns true only if all vector checks found to be clear .
bool AUSARAgent::CheckVector(FVector vector)
{
    float degStep = 6;  
    for (int circle = 1; circle < BODY_SIZE; circle++) {
        FVector endPt = FVector(circle, 0, 0);
        for (int deg = 0; deg < 360; deg += degStep) {
            FRotator rot = FRotator(0, 0, deg);
            endPt = rot.RotateVector(endPt);
            endPt = vector.Rotation().RotateVector(endPt);
            endPt = vector + TransformToWorld(endPt);
            FHitResult hitResult;
            FCollisionQueryParams queryParams;
            queryParams.AddIgnoredActor(this);
            FCollisionResponseParams responseParams;
            if (GetWorld()->LineTraceSingleByChannel(hitResult, GetActorLocation(), endPt, ECC_WorldStatic, queryParams, responseParams)) {
                return false;
            }
        }
    }
    return true;
}
bool AUSARAgent :: CheckVector ( FVector vector ) { float degStep = 6 ; for ( int circle = 1 ; circle < BODY_SIZE ; circle ++ ) { FVector endPt = FVector ( circle , 0 , 0 ) ; for ( int deg = 0 ; deg < 360 ; deg += degStep ) { FRotator rot = FRotator ( 0 , 0 , deg ) ; endPt = rot . RotateVector ( endPt ) ; endPt = vector . Rotation ( ) . RotateVector ( endPt ) ; endPt = vector + TransformToWorld ( endPt ) ; FHitResult hitResult ; FCollisionQueryParams queryParams ; queryParams . AddIgnoredActor ( this ) ; FCollisionResponseParams responseParams ; if ( GetWorld ( ) -> LineTraceSingleByChannel ( hitResult , GetActorLocation ( ) , endPt , ECC_WorldStatic , queryParams , responseParams ) ) { return false ; } } } return true ; }
Check area around vector.
Check area around vector .
// increase to increase fidelity of raycast cylinders