Compare commits

..

2 Commits

Author SHA1 Message Date
baz 29246357dc Update animation 2024-03-10 23:17:59 +00:00
baz 7d8015acf0 Play animation when Updating Health 2024-03-10 23:07:33 +00:00
4 changed files with 11 additions and 6 deletions

Binary file not shown.

Binary file not shown.

View File

@ -13,7 +13,8 @@ void UEnemyHealthbarUserWidget::BindOwner(AEnemyCharacter* NewOwner)
{ {
auto healthComponent = Owner->GetHealthComponent(); auto healthComponent = Owner->GetHealthComponent();
healthComponent->OnDamaged.BindUFunction(this, "UpdateHealthbar"); healthComponent->OnDamaged.BindUFunction(this, "UpdateHealthbar");
UpdateHealthbar(); float percent = Owner->GetHealthComponent()->GetCurrentHealth() / Owner->GetHealthComponent()->GetMaxHealth();
Healthbar->SetPercent(percent);
} }
} }
@ -22,6 +23,7 @@ void UEnemyHealthbarUserWidget::UpdateHealthbar()
if (Owner) if (Owner)
{ {
float percent = Owner->GetHealthComponent()->GetCurrentHealth() / Owner->GetHealthComponent()->GetMaxHealth(); float percent = Owner->GetHealthComponent()->GetCurrentHealth() / Owner->GetHealthComponent()->GetMaxHealth();
Healthbar->SetPercent(percent); Healthbar->SetPercent(percent);
PlayAnimation(RevealHealthbar);
} }
} }

View File

@ -21,6 +21,9 @@ public:
UPROPERTY(BlueprintReadWrite, meta = (BindWidget)) UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UProgressBar* Healthbar; UProgressBar* Healthbar;
UPROPERTY(Transient, meta = (BindWidgetAnim))
UWidgetAnimation* RevealHealthbar;
AEnemyCharacter* Owner; AEnemyCharacter* Owner;
public: public: