How to Play a SoundCue in C++
Hello guys. I want to play an Audio in C++.
I have this SoundCue:
How to play it in C++ code?
The only thing I found online is to create a new SoundCue pointer:
Thanks in advance!
asked Nov 28 '15 at 08:09 PM in C++ Programming
Sound Cues aren't played directly from source code, they are wrapped in
For a longer explanation see my blog article: playing sounds from c++ using Sound Cues
Most simple function is PlaySound2D (can't find it in API refrence for some reason):
You place SoundCue in to USoundBase argument, in WorldContextObject you place UWorld instance which you can easily get from any actor with GetWorld() function. It's static function so dont need object (thats why it needs world instance), there also location based version of this function:
Other then that there UAudioComponent which attach sound to actor
as well as AAmbientSound which is simplest sound actor
but i think you probably know how to use it, you can set them up in editor anyway
You just need to remeber that USoundCue, as well as USoundWave (you dont't need to make cue for single staticwave) is extended from USoundBase, so both will fit in USoundBase* varables and arguments
I'm also asume you know how to set that USoundCue* varable you made, if not say in comment ;]
Follow this question
Once you sign in you will be able to subscribe for any updates here