BeginPlay is too late to do this. You need to call this right after creating the default subobject.
At least, that’s what the documentation page says:
Initializes desired Attach Parent and SocketName to be attached to when the component is registered
But, like, just open up Lyra and see how they do it there:
ALyraWeaponSpawner::ALyraWeaponSpawner()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
RootComponent = CollisionVolume = CreateDefaultSubobject<UCapsuleComponent>(TEXT("CollisionVolume"));
CollisionVolume->InitCapsuleSize(80.f, 80.f);
CollisionVolume->OnComponentBeginOverlap.AddDynamic(this, &ALyraWeaponSpawner::OnOverlapBegin);
PadMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("PadMesh"));
PadMesh->SetupAttachment(RootComponent);
WeaponMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("WeaponMesh"));
WeaponMesh->SetupAttachment(RootComponent);
WeaponMeshRotationSpeed = 40.0f;
CoolDownTime = 30.0f;
CheckExistingOverlapDelay = 0.25f;
bIsWeaponAvailable = true;
bReplicates = true;
}
This should be all you need to do, assuming everything else is handled correctly. (Again – read through the Lyra code. It shows many things!)