Thank you for answering me first.
When I checked the code, I didn’t call the UpdateHpBar function. I just made it
I’m sorry but I didn’t understand this.. Can you say it again? (I’m having a little difficulty understanding it by using a translator. Please understand.)
void UOLHpBarWidget::NativeConstruct()
{
UpdateHpBar();
}
void UOLHpBarWidget::UpdateHpBar()
{
UE_LOG(LogTemp, Error, TEXT("Hp Loding..."));
APawn* Player = GetOwningPlayerPawn(); // Player 가져오기
ensure(Player);
IOLHpInterface* PlayerInterface = Cast<IOLHpInterface>(Player);
if (!PlayerInterface)
{
UE_LOG(LogTemp, Error, TEXT("Cast to IOLHpInterface failed!"));
return;
}
UpdateHp = PlayerInterface->SetHp();
UE_LOG(LogTemp, Log, TEXT("UpdateHp: %f"), UpdateHp);
if (HpBar)
{
HpBar->SetPercent(UpdateHp);
UE_LOG(LogTemp, Error, TEXT("UpdateHp"));
}
else
{
UE_LOG(LogTemp, Error, TEXT("Nooooo HpBar"));
}
}
I modified the code as above. At this time, a log called Noooo HpBar appeared. I don’t think there’s an HpBar.
I think the Hp suddenly went to zero too. The color is gone.
I think it’s correct that the HpBar was not created. And I thought about it, if the character’s Hp is reduced, they should call the UpdateHpBar function somewhere, but they didn’t call it.
The problem with my code seems to be that HpBar has not been created, and Update HpBar is not called anywhere, so it doesn’t seem to diminish when attacked.