Bug with Component Owner

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?

I assume by “rename the variable” you means the name passed as parameter(or at least including it)

If so, then afaik it’s a known bug or something like this.

As far as i understand, is that once you created subobject in constuctor and launched editor with blueprint derived from it, this blueprint stores the info about component with name you passed to CreateDefaultSubobject. The problem is that once you change the passed name - bp will hold info about the new component, as well as about the old component. Yes, you may have no old component, but once you’ll create it again - derived bp will hold all the changes that were made to this “name” before removing.

I guess it’s the reason why object behave differently depending on name. Why it’s have other owner is probably also related to that.

So, i guess your code should work as expected once you create new bp, which have no leftovers of old components.

fyi that’s the reason in my half-ready project asc is still named “ASCtest” - it will crashes for me if i try to rename it.

I think i’ve seen more in-depth report on this, but can’t find it right now