Component pointer invalid after creation in class constructor


I m adding a component to character class by using a_pointer_declare_in.h = CreateDefaultSubobject(TEXT(“Somename”));

But once the game start and using bp to check if a_pointer_declare_in.h is valid i got false do i miss some steps to get it work?

More than this in detail panel i can t see properties mark as editanywhere.

When i add the component with addcomponent button in blueprint editor those components are valid.

Any idea on the problem?

In the character .h

  1. UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Inventory, meta = (AllowPrivateAccess = “true”))
  2. class UPlayerInventory* PlayerInventory;

In the character .cpp constructor:

  1. PlayerInventory = CreateDefaultSubobject<UPlayerInventory>(TEXT(“PlayerInventory”));

Class declaration & propery declaration:

  1. UCLASS(Blueprintable, BlueprintType, meta=(BlueprintSpawnableComponent))
  2. class MYPROJECT_API UPlayerInventory : public UActorComponent
  4. UPROPERTY(EditAnywhere, Category = “Inventory”)
  5. int32 MaxSlots;

EDIT: i have the exact same problem of this guy:

That looks right for the C++ code. Can you show the BP nodes you are using to check the pointer?