OverlapSingle -> OverlapMultiByChannel
Dear Community,
OverlapSingle is deprecated and we must now decide which overlap to use from OverlapMultiByChannel
Here’s an example of how I chose to transition one of my static library functions that performs a Sphere overlap test
Old Code
static FORCEINLINE bool SphereOverlapTest(
UWorld* World,
AActor* ActorToIgnore,
const FBox& Box,
FOverlapResult& HitOut,
ECollisionChannel TraceChannel,
FQuat Rotation = FQuat::Identity
){
FCollisionQueryParams TraceParams(FName(TEXT("VictoreCore Trace")), true, ActorToIgnore);
TraceParams.bTraceComplex = true;
//Ignore Actors
TraceParams.AddIgnoredActor(ActorToIgnore);
//Re-initialize hit info
HitOut = FOverlapResult();
return World->**OverlapSingle**(
HitOut,
Box.GetCenter(),
Rotation,
TraceChannel, //! <~~~~
FCollisionShape::MakeBox(Box.GetExtent()),
TraceParams
);
}
4.8 Code
Notice I am choosing to always use the first overlap.
Please see comment by Epic Ori Cohen regarding this matter.
My current implementation is really only good for knowing if any overlaps occur at all, as the first overlap is not necessarily the closest, as per Ori’s comment above.
//New Code, Implementation is to always use the first overlap from the array.
static FORCEINLINE bool SphereOverlapTest(
UWorld* World,
AActor* ActorToIgnore,
const FBox& Box,
FOverlapResult& HitOut,
ECollisionChannel TraceChannel,
FQuat Rotation = FQuat::Identity
){
FCollisionQueryParams TraceParams(FName(TEXT("VictoreCore Trace")), true, ActorToIgnore);
TraceParams.bTraceComplex = true;
//Ignore Actors
TraceParams.AddIgnoredActor(ActorToIgnore);
//Re-initialize hit info
HitOut = FOverlapResult();
TArray<FOverlapResult> Overlaps;
bool bAnyOverlaps = World->**OverlapMultiByChannel**(
Overlaps,
Box.GetCenter(),
Rotation,
TraceChannel, //! <~~~~
FCollisionShape::MakeBox(Box.GetExtent()),
TraceParams
);
if (!bAnyOverlaps || Overlaps.Num() < 1) //extra array access safety check
{
return false;
}
//Always use first overlap!
HitOut = Overlaps[0];
return true;
}
Enjoy!

Rama