UPROPERTY is set to null by GC

Hi everyone,

I am having a problem with a property that is set to null after constructor finishes. I have a variable of UAttributeSet in my character and it is created in my constructor. This is the code:

  PrimaryActorTick.bCanEverTick = true;

  GetCapsuleComponent()->InitCapsuleSize(45.0f, 96.0f);

  AbilitySystemComp = CreateDefaultSubobject<UAbilitySystemComponent>(TEXT("AbilitySystemComponent"));

  AttributeSet = CreateDefaultSubobject<UEdenValleyAttributeSet>(TEXT("AttributeSet"));

  CharacterLevel = 1;
  bAbilitiesInitilized = false;
  bBlockAbilities = false;

After finishing this part of the code, AttributeSet is set to null. This variable is exposed to UPROPERTY so GC wouldn’t delete this variable. Also, AbilitySystemComp is declared as AttributeSet. But, for any reason, only AttributeSet is null.

Thanks in advance.

1 Like

I also met this problem and looking for the solution.Do you figure out the reason ?


Try to use Instanced property specifier on your AttributeSet property!

UEdenValleyAttributeSet* AttributeSet;

I have the same problem. Have you solved it?

Hello there,

I have hit the same problem with AttributeSet on my side, and the solution been to use the specifier transient

MyAttributeSet* AttributeSet;

Let me know if that work, Have a nice day !


This is the answer!

I have been facing a crash because the attribute set was null on duplicated BPs.

Thanks a lot!