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

View File

@ -39,6 +39,8 @@ protected:
virtual void BeginPlay() override;
private:
virtual void PlayOnFireAnimations() override;
virtual void CalculateHits(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()
{
}

View File

@ -39,6 +39,9 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TArray<TSubclassOf<AThrowable>> ThrowableInventory;
UPROPERTY(EditDefaultsOnly)
UAnimMontage* FireWeaponAnimMontage;
protected:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Meta = (AllowPrivateAccess = "true"))
UNakatomiCMC* NakatomiCMC;
@ -114,6 +117,8 @@ protected:
virtual void ProcessHits(TArray<FHitResult> hits);
virtual void PlayOnFireAnimations();
UFUNCTION()
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()
{
Super::OnDamaged();
@ -631,7 +639,7 @@ void APlayerCharacter::OnFire()
CurrentWeapon->PlayFireSoundAtLocation(this->GetTransform().GetLocation());
// TODO: Play some animation here
PlayOnFireAnimations();
CurrentWeapon->SetCurrentWeaponStatus(Cooldown);

View File

@ -91,6 +91,9 @@ public:
UPROPERTY(EditDefaultsOnly)
TArray<UAnimMontage*> OnDamagedHitAnimMontages;
UPROPERTY(EditDefaultsOnly)
UAnimMontage* FireWeaponADSAnimMontage;
protected:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
@ -246,6 +249,8 @@ protected:
virtual void CalculateHits(TArray<FHitResult>* hits) override;
virtual void ProcessHits(TArray<FHitResult> hits) override;
virtual void PlayOnFireAnimations() override;
virtual void OnDamaged() override;