Hello,
I’m trying to figure out why sometimes MyComponent will have a different Owner than the AbilitySystemComponent? I’m printing out both names OnPossess, and here’s the output:
LogActionRPG: ASC owner before possession is: BP_PlayerCharacter_C_0
LogActionRPG: MyComponent owner before possession is: Default__BP_Character_C
Note that ASC is an acronym for AbilitySystemComponent.
Having done no changes to Blueprints. I then rename the variable from MyComponent to MyComponent2, recompile and relaunch, and here’s the message now:
LogActionRPG: ASC owner before possession is: BP_PlayerCharacter_C_0
LogActionRPG: MyComponent2 owner before possession is: BP_PlayerCharacter_C_0
For reference, here is how I set up the component:
ARPGCharacterBase::ARPGCharacterBase()
{
// Create ability system component, and set it to be explicitly replicated
AbilitySystemComponent = CreateDefaultSubobject<URPGAbilitySystemComponent>(TEXT("AbilitySystemComponent"));
AbilitySystemComponent->SetIsReplicated(true);
// Create the attribute set, this replicates by default
AttributeSet = CreateDefaultSubobject<URPGAttributeSet>(TEXT("AttributeSet"));
MyComponent = CreateDefaultSubobject<UMyComponent>(TEXT("MyComponent"));
MyComponent->SetIsReplicated(true);
CharacterLevel = 1;
bAbilitiesInitialized = false;
}
Here’s how I declare MyComponent in the .h file:
UPROPERTY(Category=RPG, VisibleAnywhere, BlueprintReadOnly, meta=(AllowPrivateAccess = "true"))
TObjectPtr<class UMyComponent> MyComponent;
This is odd right? It seems like this Owner is being cached somewhere, or something weird is happening. Default__BP_Character_C looks like a Blueprint class owns the component, which shouldn’t happen right?