Component UPROPERTY is reset to default value when component is reinitialized in-game

To provide an example, let’s say there are two components “XComponent” and “YComponent” with a single UPROPERTY on each:

UPROPERTY(EditAnywhere)
float MyValue = 1.0f;

Assume “YComponent” passes “MyValue” to some external code during BeginPlay(). Also assume ‘MyValue’ was set to 2.0f via editor for “YComponent”.

While in-game changing “MyValue” on “XComponent” calls UActorComponent::PostEditChangeProperty() and updates the property.

This also causes “YComponent” to reinitialize. The issue is that when BeginPlay() is called “MyValue” is the default 1.0f, thus passing the incorrect value to the external code. “MyValue”, however, shows as the correct value of 2.0f when breaking in TickComponent().

UActorComponent::PostEditChangeProperty() is not being triggered for “YComponent”, so my question is where is “MyValue” updated after the call to BeginPlay() and how can I make sure the correct value is sent to the external code in a case like this?

bump

Same issue. Bump

I stumbled on the same issue. Basically, during the BeginPlay of a component, its data is still reset to the default values. Too bad.

1 Like