Why ViewModel created in constructor is not valid in BeginPlay?

I am trying to bind some ViewModels to my Character class, that I can use for all the instances in the future (For HP display, for example). I would assume that creating it in a constructor would be the right thing to do, but it looks like it is not, as it is not valid afterwards in the BeginPlay.

I looked through the forum, and there are a few older topics that address this, and probably the solution may be to move the creation from the constructor to the BeginPlay. Which may make it work, but can someone explain how exactly this is working? I would expect the initialized variables to be working after initialization in the constructor, but it looks like it may be modified in some way for some reason, and I would like to understand the process behind it.

Also, here is the codebase I am running:

// Sets default values
ACharacterBase::ACharacterBase()
{
    AbilitySystemComponent = CreateDefaultSubobject<UAbilitySystemComponent>(TEXT("AbilitySystemComponent"));
    HealthAttributeSet = CreateDefaultSubobject<UHealthAttributeSet>(TEXT("HealthAttributeSet"));
    
    VM_Health = CreateDefaultSubobject<UHealthViewModel>(TEXT("HealthViewModel"));
    UE_LOG(LogTemp, Log, TEXT("Constructor VM_Health: %p, IsValid=%s"), VM_Health.Get(), IsValid(VM_Health) ? TEXT("true") : TEXT("false"));
 // THIS HAS A VALID POINTER AND IS VALID
}

// Called when the game starts or when spawned
void ACharacterBase::BeginPlay()
{
	Super::BeginPlay();
	
    if (HealthAttributeSet)
    {
        // This is OK
    }
    if (AbilitySystemComponent)
    {
        AbilitySystemComponent->InitAbilityActorInfo(this, this);
        // AbilitySystemComponent is Also Fine
    }
    
    UE_LOG(LogTemp, Log, TEXT("Constructor VM_Health: %p, IsValid=%s"), VM_Health.Get(), IsValid(VM_Health) ? TEXT("true") : TEXT("false"));
     // THIS HAS VM_Health: 0x0, IsValid=false
    if (VM_Health)
    {
        VM_Health->Init(AbilitySystemComponent, HealthAttributeSet);
        UE_LOG(LogTemp, Log, TEXT("VM_Health Check: MaxHealth=%.1f, CurrentHealth=%.1f"), VM_Health->GetMaxHealth(), VM_Health->GetHealth());
    }
}

Ok, I was able to figure this out.

I was using my class as a Parent for a Blueprint. As I was working on the parent class, adding the ViewModel, the Blueprint did not get the proper defaults for it, so I needed to reinstantiate the Parent class to reset the defaults.

So basically, Blueprints created before adding a new subobject in C++ will have that subobject pointer defaulting to empty because their saved defaults don’t include it.

This may be useful for anyone who has issues with anything created with CreateDefaultSubobject.