Play animation when Updating Health
This commit is contained in:
parent
5e0433905f
commit
7d8015acf0
BIN
Content/UI/EnemyHealthbar/EnemyHealthbar.uasset (Stored with Git LFS)
BIN
Content/UI/EnemyHealthbar/EnemyHealthbar.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/UI/EnemyHealthbar/M_WhitePixel.uasset (Stored with Git LFS)
BIN
Content/UI/EnemyHealthbar/M_WhitePixel.uasset (Stored with Git LFS)
Binary file not shown.
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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:
|
||||||
|
|
Loading…
Reference in New Issue