FComponentReference Component picker non valid other actor reference

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 :cry:

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

1 Like

I found the “solution”…

I had to mess around with an override of the PostEditChangeChainProperty function, I checked the value of the FComponentReference as I set it to different components, I discovered two things:

  1. If you set it to a component of the actor that owns the FComponentReference then it DOES NOT set the OtherActor weak object pointer
  2. If you set it to a component owned by a different actor, then it sets the OtherActor pointer…

Why do it this way??..

I will leave the post up if someone else happens upon this arcane problem as well…

3 Likes