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());
    }
}