I have a level song playing - great, works fine. When a certain condition is met, I want a “Success” song played. Think of this as original Super Mario Bros, the level song and then the song when you get on the flag.
I can get it all to work except when the “success” song plays, it plays OVER the level song. There must be some sort of way to stop all sounds, or target a specific song/clip to stop?
I setup this branching system up using a “IsGameOver” boolean variable that I hoped would determine which song plays, but it doesn’t take into consideration a song already playing. How can I stop a sound already playing, that may have some length left in it.
If anyone is familiar with Flash’s ActionScript, I would use a StopAllSounds(); command - is there something like this - or a way to get this functaionlity, in Ue4?
my guess is yes you can probably write a gamemode macro that does this, you can get all sound object and stop them.
but I don’t think unreal has a built in StopAllSounds() function.
Another method would be wrap a blueprint(say SoundPlayer_BP) that does the thing you want, put it in a level, and when condition are matched(ie trigger by a triggerBox), you can stop main theme and play your success song.
I am going to have to plead ignorance and look for pitty here. When you are saying a SoundPlayer_BP, is that a custom object in Ue4? I have been reading some documentation about AudioComponents? and if I use that I can stop and play it - but I don’t want to go down that rabbit hole unless I know it’s the right direction. With an AudioComponent? I could use built in functions like stop and start?
let’s put it this way, ie. gun fire sound always follow and play at the position from pawn’s component, so if it can’t play/stop with in a blueprint, I guess UE4 needs to rewrite that part.
And no, there is no rabbit hole, experiment is highly encouraged, just don’t commit to a set of self-discovered rules while experiment with UE4.
If your game is at alpha toward beta level, then you might want to lock UE4 version as it’s a moving target to stay current.
Before that, just experiment things you want to do in a separate project and try mimic what your actual situation is, try different approach if possible so you know the pro/con of them.
I saw too many post say they already invest x hours into making their current project and are so afraid of change anything that could break their thing.
Even if there are better alternatives or more efficient methods, they kinda just too afraid to try and then either stuck there or then disappear.
Make sure you try, since you are learning a new tool, gather whatever info tutorial you need and go through all of them.
Once you have a grasp of how UE4 work, the other “new parts/features” will make more sense down the road and become easier to learn.
In his example SoundPlayer_BP would be a blueprint you make specifically to drive/control all of your audio. Then when the success or win trigger/condition is triggered/met in your sound blueprint you could kill the other sounds and play the Success Theme. I’m starting to learn that it’s pretty good to have blueprints (and blueprint interfaces) for different functions. I haven’t started to learn sound design in UE4 yet so I can only be vague with concepts, I can’t exactly help you with specifics yet.
What I would do is make the SoundPlayer_BP, create a blueprint Interface to pass on a bool to the SoundPlayer_BP (win_condition: true/false). Then when your character overlaps the trigger box for the win condition you’d pass the win_condition variable as true to the SoundPlayer_BP and that would trigger normal music to stop and win music to play. This thread, while passing different variables for a different reason, will teach you a bit about Blueprint Interface if you don’t already know: Aim Offsets Bluprint Help - Blueprint - Epic Developer Community Forums
Check that out and let me know how it goes, because I’ll be in your position soon enough (I hope anyway).
Hi all, thank you for the help. This is what I ended up doing to solve my problem:
Drag the sounds that I wanted into blueprints which created “AddAudioComponent”. Promoted both sounds to variables through return value.
Use a standard “Play” function which plays well with audio component variables to for my level music. I left auto activate checked to start immediately, but this can be unchecked and then started externally (likely how I will end up later).
To stop a sound I use a getter of the audio component variable and a “Stop” function on that variable.
To start the next sound I did the same process, driven right after the “Stop”, with another “Play” function and new audio component variable.
Good answer - this is indeed the best way to control the starting and stopping of sounds (via AudioComponents). You can also FadeIn and FadeOut AudioComponents in addition to the sudden Play and Stop functions. If you want the sounds to overlap on FadeOut, you’ll need two AudioComponents, one for the FadeOut sound and one for the FadeIn sound.
Best-
Zak