The following function causes a “Not all control paths return a value” error:
const AActor* AMeleeCharacter::FindNearestTarget()
{
// Local variables for tracing
const FVector Location = GetActorLocation();
const TArray<AActor*> ActorsToIgnore;
FHitResult HitInfo;
// Trace for nearest target
const bool TargetFound = UKismetSystemLibrary::SphereTraceSingleByProfile(
GetWorld(), Location, Location, 1000, "Pawn", false,
ActorsToIgnore, EDrawDebugTrace::None, HitInfo, true);
if(TargetFound)
{
return HitInfo.GetActor();
}
}
This is confusing to me, as I thought that was supposed to be a warning for enumerations lacking a default value. Can someone please shed some light on what this error actually means?