Hello, I want to be able to (in code) create an Ambient Sound while passing in the location of the .wav file, flag it to loop-able, then Play that ambient sound, and stop it if I need to in code. No blueprints. I am using Unreal for Rendering/Sound only. I have my own gameplay engine hooking into Unreal.
I figured it would look something like this but I can’t understand the code references in the docs. All I want to do is (pseudo code):
You don’t need any coding for that, just place sound objects around the level, it’s more optimal way to do that, so you can have different rooms and locations with different ambient sound, engine can apply stereo effects to the sound based of player location. if you want global sound played whatever you are… just add audio component to player and sound will follow the player
Also you should use SoundCues they will let you loop the sound and other interesting things, you also don’t get assets from file system for multiplatfrom compatibility and fact that your game can be installed anywhere, you need to import sound which will contain it to uasset (And then make SoundCue with it), then in C++ you can load it like this in contructor:
And SoundCue will be loaded to variable Sound you get address by right clicking asset in editor and copy reference code.
You seem to lacking knowledge about engine, i recommend you to play around with editor first to learn basics. Also you won’t avoid use of editor which you seem to want to do.
Why? What kind of ambient sound you want to make? Sound objects is not blueprint, they are coded in C++ in endine code. Also i updated my anwser as i got new ideas after
Then you can use an UAudioComponent* yourWave to handle your sound cue. yourWave can be attached to the UE Sound Cue asset using the default object finder in your calss constructor: