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?