From 3c69fc2289162d0d3db67888f5d25af31ea34c98 Mon Sep 17 00:00:00 2001 From: baz Date: Tue, 5 Mar 2024 17:00:53 +0000 Subject: [PATCH] Move OnDamagedAnimationMontages to NakatomiCharacter --- Source/Nakatomi/NakatomiCharacter.cpp | 7 +++++++ Source/Nakatomi/NakatomiCharacter.h | 3 +++ Source/Nakatomi/PlayerCharacter.cpp | 8 -------- Source/Nakatomi/PlayerCharacter.h | 3 --- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Source/Nakatomi/NakatomiCharacter.cpp b/Source/Nakatomi/NakatomiCharacter.cpp index 536c469..0a1e68c 100644 --- a/Source/Nakatomi/NakatomiCharacter.cpp +++ b/Source/Nakatomi/NakatomiCharacter.cpp @@ -275,6 +275,13 @@ void ANakatomiCharacter::PlayOnFireAnimations() void ANakatomiCharacter::OnDamaged() { + int32 randomAnimMontage = FMath::RandRange(0,OnDamagedHitAnimMontages.Num()-1); + + if (OnDamagedHitAnimMontages[randomAnimMontage] != nullptr) + { + //TODO: Disable movement while playing animation montage + PlayAnimMontage(OnDamagedHitAnimMontages[randomAnimMontage]); + } } void ANakatomiCharacter::OnDeath() diff --git a/Source/Nakatomi/NakatomiCharacter.h b/Source/Nakatomi/NakatomiCharacter.h index 648187c..dc47905 100644 --- a/Source/Nakatomi/NakatomiCharacter.h +++ b/Source/Nakatomi/NakatomiCharacter.h @@ -42,6 +42,9 @@ public: UPROPERTY(EditDefaultsOnly) UAnimMontage* FireWeaponAnimMontage; + UPROPERTY(EditDefaultsOnly) + TArray OnDamagedHitAnimMontages; + protected: UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Meta = (AllowPrivateAccess = "true")) UNakatomiCMC* NakatomiCMC; diff --git a/Source/Nakatomi/PlayerCharacter.cpp b/Source/Nakatomi/PlayerCharacter.cpp index 7de6840..2351d2d 100644 --- a/Source/Nakatomi/PlayerCharacter.cpp +++ b/Source/Nakatomi/PlayerCharacter.cpp @@ -460,14 +460,6 @@ void APlayerCharacter::PlayOnFireAnimations() void APlayerCharacter::OnDamaged() { Super::OnDamaged(); - - int32 randomAnimMontage = FMath::RandRange(0,OnDamagedHitAnimMontages.Num()-1); - - if (OnDamagedHitAnimMontages[randomAnimMontage] != nullptr) - { - //TODO: Disable movement while playing animation montage - PlayAnimMontage(OnDamagedHitAnimMontages[randomAnimMontage]); - } } void APlayerCharacter::OnDeath() diff --git a/Source/Nakatomi/PlayerCharacter.h b/Source/Nakatomi/PlayerCharacter.h index 5e7f229..b4e9ace 100644 --- a/Source/Nakatomi/PlayerCharacter.h +++ b/Source/Nakatomi/PlayerCharacter.h @@ -88,9 +88,6 @@ public: UPROPERTY(EditDefaultsOnly) UAnimMontage* ThrowExplosiveAnimMontage; - - UPROPERTY(EditDefaultsOnly) - TArray OnDamagedHitAnimMontages; UPROPERTY(EditDefaultsOnly) UAnimMontage* FireWeaponADSAnimMontage;