fix: Hpbar

Hpbar - is visible on screan
This commit is contained in:
BambiTheLama 2025-04-23 23:32:56 +02:00
parent 54396bc42c
commit 8abc59cf07
4 changed files with 5 additions and 2 deletions

Binary file not shown.

View File

@ -9,6 +9,7 @@
#include "Items/AmmoBoxBase.h"
#include "Items/HealthBoxBase.h"
#include "Player/InteractionComponent.h"
#include "Widget/UWBP_HpBar.h"
AExoPlayerCharacter::AExoPlayerCharacter()
{
@ -39,13 +40,15 @@ void AExoPlayerCharacter::BeginPlay()
if (PlayerHudClass)
{
GEngine->AddOnScreenDebugMessage(-1,5.0f,FColor::Green,TEXT("Jest klasa hudu playera"));
PlayerHud = CreateWidget<UUserWidget>(GetWorld(),PlayerHudClass);
if (PlayerHud)
{
PlayerHud->AddToViewport();
PlayerHud->AddToPlayerScreen();
GEngine->AddOnScreenDebugMessage(-1,5.0f,FColor::Green,TEXT("Dodaje to Viewportu"));
UWBP_HpBar *HpBar=Cast<UWBP_HpBar>(PlayerHud);
if (HpBar)
HpBar->SetHp(CurrentHealth,MaxHealth);
}
}
}