My default pawn in “public:”
// The SkillUserComponent that manages the stats of the user
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Properties")
USkillUserComponent *SkillUserComponent;
the pawn printing to the screen…
// Called when the game starts or when spawned
void ASkillUsingPawn::BeginPlay()
{
Super::BeginPlay();
if (SkillUserComponent) {
print("I have a SkillUserComponent");
ASkillManager *sm = nullptr;
if (IsValid(sm = Cast<AMyGameMode>(()->GetAuthGameMode())->SkillManager)) {
print("A SkillManager exists within the GameMode!");
if (IsValid(sm->MasterArsenal)) {
print("MasterArsenal is valid. Assigning to SkillUser");
SkillUserComponent->SkillSystem->Arsenal = sm->MasterArsenal;
}
}
}
}
The SkillUserComponent was being initialized in the ASkillUsingPawn constructor via…
SkillUserComponent = CreateDefaultSubobject<USkillUserComponent>(TEXT("SkillUserComponent"));
SkillUserComponent->RegisterComponent();
…and the reference remains valid here, but by the BeginPlay event, it doesn’t print anything. When I attached the components in a Blueprint and assigned them to the member variables in the ConstructionScript, THEN it worked.