Download

c++ UPROPERTY

Hello,
I have this float UPROPERTY on AI Character that keeps getting set to zero.


UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Health")
    float health;


i set it to 50.0f on the contractor
and even here


void AAI_Zombie_Character::BeginPlay()
{
    Super::BeginPlay();
    health = 50.0f;
    UE_LOG(LogTemp, Warning, TEXT("enemy Health %d"), health);

}

But the log always shows 0 and i don’t get why
If anyone can help that would be great

Edit:
never mind i set the debug to %d not %f

Yah, that mistake cost me an hour of head banging the keyboard.

Try this,



healt = 50.0f;

FString healtString = FString::SanitizeFloat(healt);

GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, (TEXT("enemy Healt "+healtString)));


or,



healt = 50.0f;

FString healtString = FString::SanitizeFloat(healt);

UE_LOG(LogTemp, Warning, TEXT("enemy Health %s"), *healtString);