UObject's Instanced value reset to C++ default value on Play?

Hello everyone,

I’m currently implementing an “Emotion Component” (that inherit from an Actor Component) that have a list of “EmotionGauge” (that inherit from a UObject and FTickableGameObject).

Unfortunately, I’m having a weird problem when I click on the “Play” in the Editor:
Some of the value in the EmotionGauge are reset to their default C++ values, and do not take the BP Value into account.

I’ll try to be clear as possible:
So, I placed a character in my current map, and I’m able to see the default value from C++ correctly:

So now I decide to change these default values in the Character BP:

If I go back to my character in the map I can see that it show the BP value and consider it as the default one:

Now, when I press play, it will get the value from the C++ file, and not from the BP:

Note that if I don’t modify the default value in the BP but directly in the instanced character in the map, it takes correctly the value and don’t reset it to C++ value

For more info, you can see the implementation below:

So the Emotion Component is an actor component that contains a list of “EmotionGauge”, here is the .h:

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class CROWDBEHAVIOR_API UEmotionComponent : public UActorComponent
{
	GENERATED_BODY()

public:	
	// Sets default values for this component's properties
	UEmotionComponent();

// ........................

protected:


    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Emotion", Instanced)
    TArray<UEmotionGauge*> EmotionGaugeList;

};

So, now in the constructor, I’m filling the Array by creating several “EmotionGauge”, here’s the .cpp:

// Sets default values for this component's properties
UEmotionComponent::UEmotionComponent()
{
	// Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
	// off to improve performance if you don't need them.
	PrimaryComponentTick.bCanEverTick = true;

    for (int i = 0; i < (int)EEmotionCategory::COUNT; ++i)
    {
        EEmotionCategory EmotionCategory = (EEmotionCategory)i;
        FString EmotionGaugeName = EnumToString("EEmotionCategory", EmotionCategory) + "Gauge";

        UEmotionGauge* NewEmotionGauge = CreateDefaultSubobject<UEmotionGauge>(FName(*EmotionGaugeName));
        EmotionGaugeList.Add(NewEmotionGauge);
    }
}

So before pressing play, in the BP everything is working fine, the array is filled correctly and for each element I can modify the value contained in the “EmotionGauge”, here is EmotionGauge.h:

UCLASS(BlueprintType)
class CROWDBEHAVIOR_API UEmotionGauge : public UObject, public FTickableGameObject
{

    GENERATED_BODY()

protected:
    UPROPERTY(EditAnywhere, Category = "Gauge Cooldown")
    bool bDoesValueChangeOverTime = false;
    // In Value/Sec. Represent the speed at which the gauge will tends to the wanted value.
    UPROPERTY(EditAnywhere, Category = "Gauge Cooldown", meta = (EditCondition = "bDoesValueChangeOverTime", ClampMin="0.0"))
    float ModifyingRate = 1.f;
    // Represent the value the gauge will tends to over time.
    UPROPERTY(EditAnywhere, Category = "Gauge Cooldown", meta = (EditCondition = "bDoesValueChangeOverTime"))
    float TargetValueForCooldown = 0.f;

    UPROPERTY(EditAnywhere, Category = "Gauge Cooldown", meta = (EditCondition = "bDoesValueChangeOverTime", ClampMin = "0.0"))
    float DelayForTriggeringCooldown = 5.f;

private:
    UPROPERTY(VisibleAnywhere, Category = "Gauge Cooldown")
    float CooldownRemainingDelay = 1.f;

};

Does anyone know what’s going on?

Thank you

Same issue for me, and I saw a lot of threads created since 2015 with the same kind of issue, but I’ve never saw an answer to this problem …

You may check out if any additional Macro in the UCLASS( … ) definition in your EmotionGauge.h or the UPROPERTY( … ) in EmotionComponent.h does help you out on this.