Change Variables of BP Instances in the Details Panel of the Level does not override the default Values, which are set in the BP itself

Hi Guys,

I have a parent class of Enemies called AEnemy, written in C++. Several Enemies are deriving via Blueprints from this C++ class. In the C++ class i have just defined some basic variables, interfaces and functions.

The problem is my fHealth variable:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “Attributes”)
float fHealth;

I can derive a BP from the C++ class, for example BP_EnemyZombie. I can change the fHealth Value in the derived Blueprint and everything is fine. So I place via Drag&Drop several BP_EnemyZombie in my level. Now I want to adjust the fHealth Variable of spezific BP_EnemyZombie, which are already placed in the level. So I click on them, adjust the fHealth in the Details Panel, but that doesnt work. UE always use the default value of the fHealth variable, which is defined in the BP_EnemyZombie itself.

I hope you can help me!

Much Thanks,
tbockmair

I think this might be an issue with where you’re setting your defaults. If you’re setting your defaults in the BeginPlay() function, then as soon as the game starts, the values you’ve set in the editor will be overridden by the C++ code. Defaults should probably be set in the constructor function, AEnemy(). That way, the defaults will be set as soon as you drag them out into the world, and won’t be overridden when you start playing the game.

Thank you for your answer!
Lets say, i define the fHealth variable in the Constructor of AEnemy with 10f or whatever.
Is it possible to change the variable via Blueprint? I have declared the fHealth variable with:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “Attributes”)

I want override the default fHealth variable of the AEnemy class in every ChildClass. There should be strong Enemies (maybe 50hp) and weak Enemies(10hp).

EDIT:
Ok, everything is working fine! I messed something in my class up.
Your answer got me the solution! :smiley:
thank you!