Tested FMOD integration by replacing some SoundAssets by FMODEvent:

Firing and reloading have been replaced.

Signed-off-by: TjgL <lithmoneo@gmail.com>
This commit is contained in:
TjgL 2025-02-22 14:31:51 +01:00
parent 0108c69639
commit 0dbef497a7
6 changed files with 18 additions and 9 deletions

Binary file not shown.

Binary file not shown.

View File

@ -31,7 +31,7 @@ void ALMRevolver::PrimaryFire()
}
PlaySound(FireSound, true);
PlayEvent(FireEvent);
PlayAnimation(PrimaryFireAnimation);
const FVector Origin = Player->GetWeaponFiringOrigin();

View File

@ -30,7 +30,7 @@ void ALMShotgun::PrimaryFire()
return;
}
PlaySound(FireSound, true);
PlayEvent(FireEvent);
PlayAnimation(PrimaryFireAnimation);
const FVector Origin = Player->GetWeaponFiringOrigin();

View File

@ -3,6 +3,7 @@
#include "Weapon/LMWeaponBase.h"
#include "FMODBlueprintStatics.h"
#include "LMUtils.h"
#include "Components/AudioComponent.h"
#include "Player/LMPlayer.h"
@ -68,6 +69,11 @@ void ALMWeaponBase::PlaySound(USoundWave* Sound, const bool Replacing)
AudioComponent->Play();
}
void ALMWeaponBase::PlayEvent(UFMODEvent* Event) const
{
UFMODBlueprintStatics::PlayEventAttached(Event, RootComponent, TEXT(""), FVector::Zero(), EAttachLocation::Type::SnapToTarget, true, true, true);
}
void ALMWeaponBase::PlayAnimation(UAnimMontage* Animation)
{
UAnimInstance* AnimInstance = WeaponMesh->GetAnimInstance();
@ -94,7 +100,7 @@ bool ALMWeaponBase::DefaultReload()
if (ClipAmmo >= MaxClip)
return false;
PlaySound(ReloadSound, true);
PlayEvent(ReloadSound);
PlayAnimation(ReloadAnimation);
State = EWeaponState::EWS_Reloading;

View File

@ -9,6 +9,7 @@
#include "LMWeaponBase.generated.h"
class UFMODEvent;
class ALMPlayer;
UCLASS()
@ -34,6 +35,8 @@ public:
UFUNCTION(BlueprintCallable)
void PlaySound(USoundWave* Sound, bool Replacing = false);
UFUNCTION(BlueprintCallable)
void PlayEvent(UFMODEvent* Event) const;
UFUNCTION(BlueprintCallable)
void PlayAnimation(UAnimMontage* Animation);
@ -71,10 +74,10 @@ protected: /* Weapon Data */
/** The sound to play when firing. */
UPROPERTY(EditAnywhere, BlueprintReadWrite,Category="Legumix|Sounds")
TObjectPtr<USoundWave> FireSound;
TObjectPtr<UFMODEvent> FireEvent;
UPROPERTY(EditAnywhere, BlueprintReadWrite,Category="Legumix|Sounds")
TObjectPtr<USoundWave> ReloadSound;
TObjectPtr<UFMODEvent> ReloadSound;
UPROPERTY(EditAnywhere, BlueprintReadWrite,Category="Legumix|Sounds")
TObjectPtr<USoundWave> DryFireSound;