Still working on my C++ and having a bit of a hard time with this one. Basically I’m looping through an array of FHitResult using RemoveAll and removing hits that are not visible using a line trace, but I want to stop doing that once I reach a predefined limit. Below is what I have so far, but doesn’t work.
UWorld* World = WorldContextObject->GetWorld();
int Found = 0;
Hits.RemoveAll([ World, TraceChannel, Location, Found, Limit ]( const FHitResult& Hit ) mutable {
FHitResult TraceHitResult;
if ( Found >= Limit ) {
return false;
}
if ( World->LineTraceSingleByChannel( TraceHitResult, ( ! Location.IsZero() ? Location : Hit.TraceStart ), Hit.ImpactPoint, TraceChannel ) ) {
return true;
}
Found++;
return false;
});
This throws the below error.
\Engine\Source\Runtime\Core\Public\Containers\Array.h(2595): error C2672: 'Invoke': no matching overloaded function found
\Engine\Source\Runtime\Core\Public\Templates\Invoke.h(63): note: could be 'unknown-type Invoke(PtrMemFunType,TargetType &&,ArgTypes &&...)'
\Engine\Source\Runtime\Core\Public\Containers\Array.h(2595): note: 'unknown-type Invoke(PtrMemFunType,TargetType &&,ArgTypes &&...)': could not deduce template argument for 'ObjType'
\Engine\Source\Runtime\Core\Public\Templates\Invoke.h(51): note: or 'unknown-type Invoke(ReturnType ObjType::* ,TargetType &&)'
\Engine\Source\Runtime\Core\Public\Containers\Array.h(2595): note: 'unknown-type Invoke(ReturnType ObjType::* ,TargetType &&)': could not deduce template argument for 'ReturnType ObjType::* ' from 'const PREDICATE_CLASS'
with
[
PREDICATE_CLASS=UTraceAttackHelpers::GetLimitedVisibleAttacksByRef::<lambda_1>
]
Can’t quite wrap my head around what it means. Anyone have any suggestions? To give some context lets say the Limit is 10. I want it to stop once doing traces it reaches 10 successful visible hits.