After a lot of time I somehow got to think about this question again, you can easily do this with a SPHERE trace for MULTI objects with the channel visibility. And then casting the results to your Class until you have hit that class or are out of results.
C++ variant:
TArray<FHitResult> OutHit;
InActor->GetWorld()->SweepMultiByChannel(OutHit, Start, End, FQuat(), ECC_Visibility, FCollisionShape::MakeSphere(50 /*Character height*/), FCollisionQueryParams::DefaultQueryParam, FCollisionResponseParams::DefaultResponseParam);
for (int i = 0; i < OutHit.Num(), i++)
{
AActor* /*Actor class*/ Tester = Cast<AActor /*Actor class*/>(OutHit[i].Actor);
if (Tester)
{
return Tester;
}
}
//Written in 5 mins, not tested but should work, may need to check the returning ![]()
I know it is late, but I thought I would write it anyway;