Hi,
I am running into a really frustrating problem where components created/added through C++ constructor don’t get initialized correctly if I spawn the BP version of the class in runtime.
However, if I were to place the BP directly into the world in editor, all components initialize and function properly before and during runtime.
From what I have deduced, it seems like the components may be getting initialized out of order causing them to function incorrectly.
I need these components to be preset with some configs when a BP is created of this class, so I can’t simply just make a variable and then add the components in BP.
Any help would be appreciated!
Here is sample code:
//Constructor Function
APickUpObject::APickUpObject()
{
PrimaryActorTick.bCanEverTick = true;
Grabbable = CreateDefaultSubobject<UGrabbingComponent>(TEXT("Grabbable"));
Grabbable->SetupAttachment(GetRootComponent());
Grabbable->RegisterComponent();
Grabbable->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_No;
Grabbable->SetCollisionProfileName(TEXT("Grabbable"));
Grabbable->SetGenerateOverlapEvents(true);
}```