No sound happens when I fire? I also tried to apply a sound for my health pickup and ammo pickup but can’t seem to get them to work either. What I am doing wrong?
My .cpp file
AWeapon::AWeapon(const FObjectInitializer& projectileVar)
: Super(projectileVar)
{
AudioComp = CreateDefaultSubobject<UAudioComponent>(TEXT("AudioComp"));
AudioComp->AttachParent = RootComponent;
AudioComp->bAutoActivate = false;
AudioComp->bAutoDestroy = false;
}
void AWeapon::Fire()
{
if (LazerGun)
{
AudioComp->SetSound(LazerGun);
AudioComp->Play();
}
}
.h file
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Sound")
UAudioComponent* AudioComp;
UPROPERTY(EditDefaultsOnly, Category = "Sound")
USoundCue* LazerGun;