I have a USceneComponent called UInteractionTrigger
. It has a UPrimitiveComponent
as a UProperty that is edited inline in the details panel.
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Interaction)
UPrimitiveComponent* InteractionCollider;
Now, if I add it to a Actor in blueprint, I am able to edit the values and everything works fine.
But, if I add it from cpp as follows,
In WeaponBase.h,
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Weapon | Default")
UInteractionTrigger* InteractionTrigger;
In WeaponBase.cpp in the constructor,
InteractionTrigger = CreateDefaultSubobject<UInteractionTrigger>(TEXT("Interaction Trigger"));
If i edit the value in a child blueprint of WeaponBase.h, the value if being reset every time I press compile.
- I am setting the Interaction collider value as Box collision from details panel and value is getting reset to none
- Like this,
I am not sure if it is a bug in unreal editor or if something is wrong in my code, though I am not manually setting the value to nullptr
anywhere in my code.