Actor Component UPROPERTY resets value when compiling

Hi! If I change the value of an UPROPERTY belonging to an “Actor Component” inside a blueprint and then compile the C++ code all values get reset to the default value specified in the header-file. If I change values of an instance they get kept but all changes inside a blueprint get reset.

For example, if I change the value of “MaxPitch” inside a blueprint to 90 and then compile, it resets to 45.

UPROPERTY(EditAnywhere) float MaxPitch = 45.f;

I’ve tried compiling directly from Visual Studio, inside the editor, having the editor closed when compiling but nothing works. This happens to all my Actor Components and on all blueprints on which they are used.

For AActor classes it seems to keep its values correctly but UActorComponent doesn’t work.

What am I doing wrong?

Default values should be specified inside Constructor function, not in header.

That makes no difference. Specifying them in the header is the more modern way, and just generates identical code for the constructor.

If the class later has to use LoadConfig() that becomes a silent nest of weirdness…
Btw, I guess OP isn’t creating blueprints for the component classes?

If you create a BP then attach it, instead of attaching the base component class, then the component should be able to keep its own default values.

I tried putting the default value in the constructor it made no difference in this case.

I’m not sure I follow along. The way I do it is inside the editor I create a blueprint, inside that blueprint, I click “Add Component” and from there I add my C++ component, is it what you mean?

Yes, if you create a Blueprint based on your Component class, does that still happens?
(Component Blueprints appear in the “Custom” section of Add Component list)

Unreal Supports C++ 11 to some extent, default member intilization is one them so no need to initialize in the constructor. I might read your first post wrong but a blueprint based of your class will most likely return to your specified default value, that has been around for ages as a “issue”

I have several Component Blueprints and they only reset to CPP default values if the property in CDO was never marked “dirty” (modified).

As long I change the default value of CDO even if I change things in C++ later, the defaults in CDO remain their own because now the Component has its own “GeneratedClass”.
In general it’s my personal experience, unless you’re talking about hotReload which I don’t use at all.

To clarify: it is an “Actor Component” that reverts to default value, not an “Actor”. For “Actor” it seems to remember the values when compiling, but for “Actor Component” it does not. Is it “Actor Components” you mean is this "issue that has been around for ages?

I’m kinda new to C++ in Unreal so I’m using HotReload yes, what is the alternative?

I’ve tried finding an answer on how to mark as “dirty” with CDO, can you elaborate a bit more about this process? And is it not possible with HotReload?