You can do something like this:
// try and play the sound if specified
UGameplayStatics::PlaySoundAtLocation(pWorld, def->FireSound, SpawnLocation);
You should replace pWorld by GetWorld() and SpawnLocation by the location you want, weapon muzzle for instance
I might be just terrible at googling around, but I mostly only found examples from older versions that don’t seem to work the same anymore.
So I have my sound file, and I want to apply it to my Fire(), so when the user fires, the sound plays. Do I have to turn the sound wave into a Que first? And are there any good step by step tutorials showing how to then set it up in your code that I may have missed?
Surely this is a unusual way? Should you not just be able to play the sound on shooting. Not have to spawn it in?
I don’t think i’m getting your point. You also have PlaySound2D which takes a world context and a sound.
Everything depends on your needs. Indeed you can use an audio component but this requires setting up your character with another component which is not complex but still more than a 1 line of code.
Well for example I tried using UAudioComponent, and following How do i play a sound UAudioComponent? - Audio - Epic Developer Community Forums As I imagined it would be similar to that?
Sorry it works now. Is it possible to see an example? As I’m guessing there is a reason people do it that way?