I’m doing a sphere trace, and sometimes it happens that the trace results in a hit, but the Actor hit doesn’t actually exists.
The code looks like this:
FHitResult sphereTraceHitResult;
bool sphereTraceHit = GetWorld()->SweepSingleByChannel(sphereTraceHitResult, rayStart, rayEnd, FQuat(), ECollisionChannel::ECC_Visibility, FCollisionShape::MakeSphere(5), QueryParams);
if(sphereTraceHit)
{
AActor *hitActor = pHitResult.Actor.Get();
// Sometimes this prints 1, meaning that the actor is NULL
UE_LOG(LogTemp, Warning, TEXT("hitActor is NULL: %d"), hitActor == nullptr);
}
I don’t understand why this is happening. If there is a hit, shouldn’t there ALWAYS be a hit actor?