Can't assign a value to a variable in constructor

Hello, I wanted to know why I can’t assign my variable to value in constructor?

MainCharacter.h

UCLASS()
class GAME_API AMainCharacter : public ACharacter
{
	GENERATED_BODY()

private:

	UPROPERTY(EditAnywhere, Category = "Needs | Helth")
	float CurrentHelth;

	UPROPERTY(EditAnywhere, Category = "Needs | Helth")
	float InitialHelth;

public:

    virtual void Tick(float DeltaTime) override;

    AMainCharacter();

    UFUNCTION(BlueprintPure, Category = "Needs | Helth")
    float GetInitialHelth();

    UFUNCTION(BlueprintPure, Category = "Needs | Helth")
    float GetCurrentHelth();

    virtual void BeginPlay() override;
};

MainCharacter.cpp

AMainCharacter::AMainCharacter()
{
	PrimaryActorTick.bCanEverTick = true;

	InitialHelth = 100.f;
	CurrentHelth = InitialHelth;
}

And when debug I see that InitialHelth = 0 and CurrentHelth.
What am I doing wrong?

Hi Sh1ftO_o ,

I’m guessing that you are running a Development build, and that optimization is happening, resulting in the variables to be assigned in a different order. My guess is that you have to press F10 and look at the AMainCharacter variable after the construction is done (or even add a breakpoint to Event Begin Play), or change your configuration to Debug.

Oh, thank you. It works. I select DebugGame Editor. You are the best !