Compare commits
2 Commits
4e99898af9
...
a25f08b832
Author | SHA1 | Date |
---|---|---|
baz | a25f08b832 | |
baz | 2320014f72 |
Binary file not shown.
BIN
Content/UI/HUD/WidgetHUD.uasset (Stored with Git LFS)
BIN
Content/UI/HUD/WidgetHUD.uasset (Stored with Git LFS)
Binary file not shown.
|
@ -36,3 +36,28 @@ void UPlayerHUDWidget::ShowHitMarker()
|
||||||
PlayAnimation(RevealHitmarker, 0.0f, 1, EUMGSequencePlayMode::Forward, 1.0f);
|
PlayAnimation(RevealHitmarker, 0.0f, 1, EUMGSequencePlayMode::Forward, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FString UPlayerHUDWidget::GetHealthbarText(APlayerCharacter* PlayerCharacter)
|
||||||
|
{
|
||||||
|
int healthbarCharacters = 5;
|
||||||
|
float normalised = PlayerCharacter->GetHealthComponent()->GetCurrentHealth() /
|
||||||
|
PlayerCharacter->GetHealthComponent()->GetMaxHealth();
|
||||||
|
float adjusted = normalised * healthbarCharacters;
|
||||||
|
int segments = FMath::RoundToInt(adjusted);
|
||||||
|
|
||||||
|
FString healthBar = FString("[");
|
||||||
|
|
||||||
|
for (int i = 0; i < segments; i++)
|
||||||
|
{
|
||||||
|
healthBar.Append("=");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = segments; i < healthbarCharacters; i++)
|
||||||
|
{
|
||||||
|
healthBar.Append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
healthBar.Append("]");
|
||||||
|
|
||||||
|
return healthBar;
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include "Blueprint/UserWidget.h"
|
#include "Blueprint/UserWidget.h"
|
||||||
#include <Components/TextBlock.h>
|
#include <Components/TextBlock.h>
|
||||||
#include <Components/Image.h>
|
#include <Components/Image.h>
|
||||||
|
|
||||||
|
#include "PlayerCharacter.h"
|
||||||
#include "PlayerHUDWidget.generated.h"
|
#include "PlayerHUDWidget.generated.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,6 +31,9 @@ public:
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void ShowHitMarker();
|
void ShowHitMarker();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
FString GetHealthbarText(APlayerCharacter* PlayerCharacter);
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||||
UTextBlock* HealthText;
|
UTextBlock* HealthText;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue