On Component Begin Overlap Sweep Result not populated

I’m having the same problem and worked around it by doing a spherical sweep when I get the overlap event. This seems to work for me, but I also use a spherical collision hull. Here is my code, slightly simplified to be more generic:

void AMyPawn::OnComponentBeginOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
	if (OtherActor && (OtherActor != this))
	{
		TArray<FHitResult> AllResults;

		// Get the location of this actor
		auto Start = GetActorLocation();
		// Get the location of the other component
		auto End = OtherComp->GetComponentLocation();
		// Use a slightly larger radius to ensure we find the same result
		auto CollisionRadius = FVector::Dist(Start, End) * 1.1f;

		// Now do a spherical sweep to find the overlap
		GetWorld()->SweepMultiByObjectType(
			AllResults,
			Start,
			End,
			FQuat::Identity,
			0,
			FCollisionShape::MakeSphere(CollisionRadius),  
			FCollisionQueryParams::FCollisionQueryParams(false)
		);

		// Finally check which hit result is the one from this event
		for (auto HitResult : AllResults)
		{
			if (OtherComp->GetUniqueID() == HitResult.GetComponent()->GetUniqueID()) {
				// A component with the same UniqueID means we found our overlap!
				
				// Do your stuff here, using info from 'HitResult'
				OnComponentBeginOverlapWithInfo(OtherActor, OtherComp, OtherBodyIndex, bFromSweep, HitResult);
			
				break;
			}
		}
	}
}

This solution sucks, but it’s the best I could come up with. You could probably still tweak it a bit with the parameters of SweepMultiByObjectType. In particular I suspect FCollisionObjectQueryParams and FCollisionQueryParams could be used to reduce the search space.

I hope this will help someone, somehow :slight_smile: but it would be great to hear a better solution!

3 Likes