Play Weapon Fire Sound in OnFire

This commit is contained in:
Louis Hobbs 2023-01-18 00:35:06 +00:00
parent a266215e98
commit 7c44598084
3 changed files with 14 additions and 2 deletions

View File

@ -384,7 +384,6 @@ void APlayerCharacter::RemoveWeaponFromInventory(int i)
void APlayerCharacter::RemoveCurrentWeaponFromInventory()
{
// TODO: Add more checking here
}
void APlayerCharacter::OnFire()
@ -406,7 +405,9 @@ void APlayerCharacter::OnFire()
RemoveCurrentWeaponFromInventory();
}
// TODO: Play sound effect
CurrentWeapon->PlayFireSoundAtLocation(GetActorLocation());
// TODO: Play some animation here
CurrentWeapon->SetCurrentWeaponStatus(WeaponState::Cooldown);
}

View File

@ -2,6 +2,7 @@
#include "Weapon.h"
#include <Kismet/GameplayStatics.h>
// Sets default values
AWeapon::AWeapon()
@ -68,6 +69,14 @@ void AWeapon::SetFireSound(USoundBase* USoundBase)
FireSound = USoundBase;
}
void AWeapon::PlayFireSoundAtLocation(FVector location)
{
if (!FireSound)
{
UGameplayStatics::PlaySoundAtLocation(this, FireSound, location);
}
}
int AWeapon::GetAmmoCount()
{
return AmmoCount;

View File

@ -104,6 +104,8 @@ public:
void SetFireSound(USoundBase* USoundBase);
void PlayFireSoundAtLocation(FVector location);
int GetAmmoCount();
void SetAmmoCount(int ammoCount);