I’m trying to iterate through a TArray and move the Actor in each FOVerlapResult into a seperate TArray:
UPROPERTY(VisibleAnywhere)
AActor* myActor;
UPROPERTY(VisibleAnywhere)
TArray<FOverlapResult> overlaps;
for (int i = 0; i < overlaps.Num(); i++){
if (actorArray.Contains(overlaps[i])){
}
else
{
actorArray.Add(overlaps[i].Actor);
}
}
However, this is producing a single error, "error C2664: ‘int32 TArray::Add(AActor *const &)’ : cannot convert argument 1 from ‘TWeakObjectPtr’ to ‘AActor *&&’ ".
I’m been staring at this for a while, but I can’t figure out where the mistake is- am I trying to assign a variable to a pointer or vice-versa somewhere?
overlaps[i].Actor is a weak pointer, you would need to do *overlaps[i].Actor or overlaps[i].Actor.Get() depending on what actorArray is (pointer or reference/copy).
I’m 99% sure that alone solves it, but changing to overlaps[i].Actor.Get() produces a really weird error linked to Array.h, “binary ‘==’ : no operator found which takes a right-hand operand of type ‘const FOverlapResult’ (or there is no acceptable conversion)”. Is there any chance you know what that is? I changed OverlapMulti to UWorld::OverlapMultiByChannel | Unreal Engine Documentation because the former is getting phased out, but to my eyes they take and return the same data.