Play Weapon Fire Sound in OnFire
This commit is contained in:
parent
a266215e98
commit
7c44598084
|
@ -384,7 +384,6 @@ void APlayerCharacter::RemoveWeaponFromInventory(int i)
|
||||||
void APlayerCharacter::RemoveCurrentWeaponFromInventory()
|
void APlayerCharacter::RemoveCurrentWeaponFromInventory()
|
||||||
{
|
{
|
||||||
// TODO: Add more checking here
|
// TODO: Add more checking here
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APlayerCharacter::OnFire()
|
void APlayerCharacter::OnFire()
|
||||||
|
@ -406,7 +405,9 @@ void APlayerCharacter::OnFire()
|
||||||
RemoveCurrentWeaponFromInventory();
|
RemoveCurrentWeaponFromInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Play sound effect
|
CurrentWeapon->PlayFireSoundAtLocation(GetActorLocation());
|
||||||
|
|
||||||
|
// TODO: Play some animation here
|
||||||
|
|
||||||
CurrentWeapon->SetCurrentWeaponStatus(WeaponState::Cooldown);
|
CurrentWeapon->SetCurrentWeaponStatus(WeaponState::Cooldown);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "Weapon.h"
|
#include "Weapon.h"
|
||||||
|
#include <Kismet/GameplayStatics.h>
|
||||||
|
|
||||||
// Sets default values
|
// Sets default values
|
||||||
AWeapon::AWeapon()
|
AWeapon::AWeapon()
|
||||||
|
@ -68,6 +69,14 @@ void AWeapon::SetFireSound(USoundBase* USoundBase)
|
||||||
FireSound = USoundBase;
|
FireSound = USoundBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AWeapon::PlayFireSoundAtLocation(FVector location)
|
||||||
|
{
|
||||||
|
if (!FireSound)
|
||||||
|
{
|
||||||
|
UGameplayStatics::PlaySoundAtLocation(this, FireSound, location);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int AWeapon::GetAmmoCount()
|
int AWeapon::GetAmmoCount()
|
||||||
{
|
{
|
||||||
return AmmoCount;
|
return AmmoCount;
|
||||||
|
|
|
@ -104,6 +104,8 @@ public:
|
||||||
|
|
||||||
void SetFireSound(USoundBase* USoundBase);
|
void SetFireSound(USoundBase* USoundBase);
|
||||||
|
|
||||||
|
void PlayFireSoundAtLocation(FVector location);
|
||||||
|
|
||||||
int GetAmmoCount();
|
int GetAmmoCount();
|
||||||
|
|
||||||
void SetAmmoCount(int ammoCount);
|
void SetAmmoCount(int ammoCount);
|
||||||
|
|
Loading…
Reference in New Issue