I have something like this on my code:
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta=(UseComponentPicker, AllowAnyActor, AllowedClasses="/Script/ProjectName.ComponentClass"))
TArray<FComponentReference> ComponentArray;
On the editor it works perfect, the designers on my team can fill the array the way they want and it filters the component class correctly as well, the problems come at runtime, where I need to get the component’s hard reference:
const FComponentReference& compReference = var.ComponentArray[i];
UE_LOG(LogTemp, Warning, TEXT("%s comp name"), *compReference.PathToComponent);
UE_LOG(LogTemp, Warning, TEXT("%d act is valid"), compReference.OtherActor.IsValid());
if(compReference.OtherActor.IsValid())
UE_LOG(LogTemp, Warning, TEXT("%s act name"), *compReference.OtherActor.Get()->GetName());
UComponentClass* comp = Cast<UComponentClass>(compReference.GetComponent(nullptr));
if(!comp)
{
UE_LOG(LogTemp, Warning, TEXT("%s trigger spawner not valid! %s"), *this->GetName(), *compReference.PathToComponent);
}
else
{
// specific component logic here
}
it never enters the if(compReference.OtherActor.IsValid())
conditional, so when the function GetComponent
is called with nullptr
, it returns a nullptr
as well…
If I pass the correct actor reference to that function the component is found and the hard reference is correct and the flow enters the else clause where the logic happens, the problem is that I can’t hardcode the actor reference as I need it to be found from the component reference object
Does anyone know if the component picker has a bug or something? I couldn’t find anything on google, the official docs don’t help at all, a reddit post said “make one yourself”, was pretty old, and addressed another issue that has since been solved (component class filtering) u.u