From 7d8015acf05c92174a2a5181b175d99418a9cca3 Mon Sep 17 00:00:00 2001 From: baz Date: Sun, 10 Mar 2024 23:07:33 +0000 Subject: [PATCH] Play animation when Updating Health --- Content/UI/EnemyHealthbar/EnemyHealthbar.uasset | 4 ++-- Content/UI/EnemyHealthbar/M_WhitePixel.uasset | 4 ++-- Source/Nakatomi/UI/EnemyHealthbarUserWidget.cpp | 6 ++++-- Source/Nakatomi/UI/EnemyHealthbarUserWidget.h | 3 +++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Content/UI/EnemyHealthbar/EnemyHealthbar.uasset b/Content/UI/EnemyHealthbar/EnemyHealthbar.uasset index 4d91056..6ac4b27 100644 --- a/Content/UI/EnemyHealthbar/EnemyHealthbar.uasset +++ b/Content/UI/EnemyHealthbar/EnemyHealthbar.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:43a7361d44a2ccdb3eb9e20be5452bd6a89e5cd2a8d326297e3cd33a2fb9193b -size 28664 +oid sha256:fa87c70eb372280688cc2d3b3f7384f4471f9ea325eb7cee8e2ba2ae54ed2c26 +size 41706 diff --git a/Content/UI/EnemyHealthbar/M_WhitePixel.uasset b/Content/UI/EnemyHealthbar/M_WhitePixel.uasset index 44cbf8c..29b98e7 100644 --- a/Content/UI/EnemyHealthbar/M_WhitePixel.uasset +++ b/Content/UI/EnemyHealthbar/M_WhitePixel.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4084c4fb20a8d2e2bd30c146dcdd994a076e7ec8b3ee2453f6606174134a343a -size 6552 +oid sha256:3efa23f477c1f6d934b0293cfcf2d8b628ce24ab16ba1fe1056e2d4034f5fb3a +size 6798 diff --git a/Source/Nakatomi/UI/EnemyHealthbarUserWidget.cpp b/Source/Nakatomi/UI/EnemyHealthbarUserWidget.cpp index 90fb329..704c92c 100644 --- a/Source/Nakatomi/UI/EnemyHealthbarUserWidget.cpp +++ b/Source/Nakatomi/UI/EnemyHealthbarUserWidget.cpp @@ -13,7 +13,8 @@ void UEnemyHealthbarUserWidget::BindOwner(AEnemyCharacter* NewOwner) { auto healthComponent = Owner->GetHealthComponent(); 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) { float percent = Owner->GetHealthComponent()->GetCurrentHealth() / Owner->GetHealthComponent()->GetMaxHealth(); - Healthbar->SetPercent(percent); + Healthbar->SetPercent(percent); + PlayAnimation(RevealHealthbar); } } diff --git a/Source/Nakatomi/UI/EnemyHealthbarUserWidget.h b/Source/Nakatomi/UI/EnemyHealthbarUserWidget.h index d48f0e9..1a481c9 100644 --- a/Source/Nakatomi/UI/EnemyHealthbarUserWidget.h +++ b/Source/Nakatomi/UI/EnemyHealthbarUserWidget.h @@ -21,6 +21,9 @@ public: UPROPERTY(BlueprintReadWrite, meta = (BindWidget)) UProgressBar* Healthbar; + UPROPERTY(Transient, meta = (BindWidgetAnim)) + UWidgetAnimation* RevealHealthbar; + AEnemyCharacter* Owner; public: