So I’m following this nice Tutorial playlist on the Unreal Engine Youtube channel where you have to create a character that can “charge up” using randomly spawned batteries.
The issue is the following: in the C++ code we see in the video, 2 variables (among others) are created for the Character
InitialPower, that states the starting power of our character
protected:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Power", Meta = (BlueprintProtected="true"))
float InitialPower;
CharacterPower, that stores the starting power of our character and won’t be editable.
private:
UPROPERTY(VisibleAnywhere, Category = "Power")
float CharacterPower;
In the constructor, this is how these 2 variables are implemented
InitialPower = 2000.f;
CharacterPower = InitialPower;
The problem is, if I decide to edit InitialPower from the Unreal Editor using the CharacterBlueprint, once I start the play mode this assignment won’t be executed.
No matter if I decide to set InitialPower to 1000 or 0, once the game starts the CharacterPower variable will always be initialized with a value of 2000. Sure I could make editable CharacterPower but I want to understand why this is happening.