Reference Blueprint Component


I have a class that inherits from APawn, and the class is used in the Blueprint Graph Editor. How would I create a class member that would reference another component in the Blueprint?

Basically, several components are added together to create the final object. Now I need to reference different parts of the object via C++. I can’t seem to get this to work with:

TAssetPtr<AActor> myVar;
AActor* myVar;

TAssetPtr<UStaticMeshComponent> myVar;
UStaticMeshComponent* myVar;

because the components are Static Mesh Components. I can assemble components in the Graph Editor Viewport but the components added are not considered Actors. Additionally, components could span the gamut, and I would like a more robust and generic solution if one exists.

When using UUserWidget I have used WidgetTree and searched for a hardcoded name, something I don’t like, but if possible, I’d like to use a class member to point to the object that needs to be manipulated.

Can someone help?

Thank you.

In case anyone else is interested I am scanning through the GetComponents list during the BeginPlay() call:

    UStaticMeshComponent* partOne;
    UStaticMeshComponent* partTwo;


void AMyCustomPawn::BeginPlay()
    const FName partOneName = FName("Part_One");
    const FName partTwoName = FName("Part_Two");

    partOne = nullptr;
    partTwo = nullptr;

    const TArray<UActorComponent*>& theComponents = GetComponents();

    int32 componentCount = theComponents.Num();
    for (int32 x = 0; x < componentCount; x++)
        UStaticMeshComponent* theMesh = Cast<UStaticMeshComponent>(theComponents[x]);
        if (theMesh)
            if (theMesh->GetFName().Compare(partOneName) == 0)
                partOne = theMesh;

            if (theMesh->GetFName().Compare(partTwoName) == 0)
                partTwo = theMesh;

Then during the Tick call I can manipulate the individual parts as needed:

void AMyCustomPawn::Tick( float DeltaTime )
    Super::Tick( DeltaTime );

    if (partOne != nullptr)

    if (partTwo != nullptr)

Of course I’d rather have a class member that could be assigned to in the blueprint, and access the part that way.