Play Fire animation during OnFire

This commit is contained in:
baz 2024-02-05 22:35:28 +00:00
parent 0644a807ba
commit e26b66b7aa
10 changed files with 46 additions and 6 deletions

Binary file not shown.

Binary file not shown.

BIN
Content/Enemy/Worker/C_Worker.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Content/Player/PlayerCharacter.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -2,6 +2,7 @@
#include "EnemyCharacter.h" #include "EnemyCharacter.h"
#include "EnemyAIController.h" #include "EnemyAIController.h"
#include "InteractableComponent.h"
#define COLLISION_WEAPON ECC_GameTraceChannel1 #define COLLISION_WEAPON ECC_GameTraceChannel1
@ -29,7 +30,7 @@ void AEnemyCharacter::OnFire()
CurrentWeapon->PlayFireSoundAtLocation(GetActorLocation()); CurrentWeapon->PlayFireSoundAtLocation(GetActorLocation());
// TODO: Play some animation here PlayOnFireAnimations();
CurrentWeapon->SetCurrentWeaponStatus(Cooldown); CurrentWeapon->SetCurrentWeaponStatus(Cooldown);
@ -50,6 +51,11 @@ void AEnemyCharacter::BeginPlay()
Super::BeginPlay(); Super::BeginPlay();
} }
void AEnemyCharacter::PlayOnFireAnimations()
{
Super::PlayOnFireAnimations();
}
void AEnemyCharacter::CalculateHits(TArray<FHitResult>* hits) void AEnemyCharacter::CalculateHits(TArray<FHitResult>* hits)
{ {
// Set up randomness // Set up randomness

View File

@ -39,6 +39,8 @@ protected:
virtual void BeginPlay() override; virtual void BeginPlay() override;
private: private:
virtual void PlayOnFireAnimations() override;
virtual void CalculateHits(TArray<FHitResult>* hits) override; virtual void CalculateHits(TArray<FHitResult>* hits) override;
virtual void ProcessHits(TArray<FHitResult> hits) override; virtual void ProcessHits(TArray<FHitResult> hits) override;

View File

@ -262,6 +262,14 @@ void ANakatomiCharacter::ProcessHits(TArray<FHitResult> hits)
{ {
} }
void ANakatomiCharacter::PlayOnFireAnimations()
{
if (!GetCrouched())
{
PlayAnimMontage(FireWeaponAnimMontage);
}
}
void ANakatomiCharacter::OnDamaged() void ANakatomiCharacter::OnDamaged()
{ {
} }

View File

@ -39,6 +39,9 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TArray<TSubclassOf<AThrowable>> ThrowableInventory; TArray<TSubclassOf<AThrowable>> ThrowableInventory;
UPROPERTY(EditDefaultsOnly)
UAnimMontage* FireWeaponAnimMontage;
protected: protected:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Meta = (AllowPrivateAccess = "true")) UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Meta = (AllowPrivateAccess = "true"))
UNakatomiCMC* NakatomiCMC; UNakatomiCMC* NakatomiCMC;
@ -114,6 +117,8 @@ protected:
virtual void ProcessHits(TArray<FHitResult> hits); virtual void ProcessHits(TArray<FHitResult> hits);
virtual void PlayOnFireAnimations();
UFUNCTION() UFUNCTION()
virtual void OnDamaged(); virtual void OnDamaged();

View File

@ -440,6 +440,14 @@ void APlayerCharacter::ProcessHits(TArray<FHitResult> hits)
} }
} }
void APlayerCharacter::PlayOnFireAnimations()
{
if (!GetCrouched())
{
PlayAnimMontage(IsADS ? FireWeaponADSAnimMontage : FireWeaponAnimMontage);
}
}
void APlayerCharacter::OnDamaged() void APlayerCharacter::OnDamaged()
{ {
Super::OnDamaged(); Super::OnDamaged();
@ -631,7 +639,7 @@ void APlayerCharacter::OnFire()
CurrentWeapon->PlayFireSoundAtLocation(this->GetTransform().GetLocation()); CurrentWeapon->PlayFireSoundAtLocation(this->GetTransform().GetLocation());
// TODO: Play some animation here PlayOnFireAnimations();
CurrentWeapon->SetCurrentWeaponStatus(Cooldown); CurrentWeapon->SetCurrentWeaponStatus(Cooldown);

View File

@ -92,6 +92,9 @@ public:
UPROPERTY(EditDefaultsOnly) UPROPERTY(EditDefaultsOnly)
TArray<UAnimMontage*> OnDamagedHitAnimMontages; TArray<UAnimMontage*> OnDamagedHitAnimMontages;
UPROPERTY(EditDefaultsOnly)
UAnimMontage* FireWeaponADSAnimMontage;
protected: protected:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
float SprintSpeedMultiplier = 2.0f; float SprintSpeedMultiplier = 2.0f;
@ -247,6 +250,8 @@ protected:
virtual void ProcessHits(TArray<FHitResult> hits) override; virtual void ProcessHits(TArray<FHitResult> hits) override;
virtual void PlayOnFireAnimations() override;
virtual void OnDamaged() override; virtual void OnDamaged() override;
virtual void OnDeath() override; virtual void OnDeath() override;