Changing the background music?

I was wondering, how does one go about changing the background music to something else via blueprint?

Specifically, I’ve been working on adding a death animation to my player character and I want to play a short tune when the player dies but I don’t know how to switch songs.

Any help whatsoever would be greatly appreciated!

1 Like

How are you playing the current music?

1 Like

Like :

1 Like

A Ambient Sound Actor placed in the level.

How do I access component? I can’t seem to find it anywhere.

342684-ambientsound.jpg

I placed an ambient sound in the level, then went to the level BP and right clicked on the graph, you get a reference to the actor that you had selected in the level.

1 Like

has to be in the level blueprint? Hrm, I’m not sure about that since I’m trying to make a musical cue that plays when the player character dies and so I think it would be best if it were in player’s blueprint since it carries over from level to level.

1 Like

No it doesn’t, but if you show me how you’re doing it now, I will show you how to go about it…

Well, is my current death animation setup.

1 Like

You haven’t shown how you are currently trying to play and stop the music.

Can someone please help me out. I’ve tried searching online and I haven’t been able to find anything related to issue. I honestly don’t know what else I can do at point.

I currently don’t have anything for playing and stopping music, the death animation setup I posted above is all that I have.

It’s been awhile, way too long, but since I last posted all I’ve managed to accomplish is add the death jingle to the death code.

I still can’t figure out how to stop the background music, as I can’t seem to find any tutorials online on how to help me out. I just find it baffling that something that seems so basic as stopping background music can be so frustratingly complicated :face_with_symbols_over_mouth:.

1 Like

If you pull off the pin marked Return Value on the Spawn Sound 2D and create a variable from it. That will be setting a reference. You can use that reference to feed into a Fade or a Stop, which will either fade out the sound and stop it, or just outright stop it.

Realize though that if you are doing in player character and the player character will be destroyed depending on your death logic method, you may have to place to Stop or Fade for your sound elsewhere. There are other places you could do both the sound spawn and the Stop or Fade that might be intact longer. For example, PlayerController, GameMode or any logical place that won’t be destroyed with your player character while you respawn it. If your player character is not actually going to be destroyed and respawned, then it’s fine to do both the sound spawn and the fade or stop there.

Why don’t you use side chaining, using a submix + soundclass combination?

The problem I’m having is that I don’t just need to stop the BGM for the current level I’m using for testing but also for all others levels, as well as other things like boss battle music. Basically I need a universal way to stop music and that’s what I can’t figure out how to do.

The only reason I have the logic for death contained within the player character blueprint is that I don’t know how to do the animation logic from elsewhere like the Player Controller blueprint. I would prefer the logic to be not

contained within the player character blueprint as I’m planning on having multiple playable characters & I don’t want to have to code the death logic for each individual character. Its not really a priority right now, for the time being I’m just focusing on trying to get the death logic to work for one character and then later figure how to change it so that it can be applied to everyone.

The player character being destroyed isn’t an issue, at least in my game’s current state, as the level resets upon the player’s death rather than destroying the player character.

I’m not sure what side chaining is, but I’ve been trying to look into soundclass, I just haven’t had much luck in trying to figure how to make it work for my own purposes.

Hi side chaining is a typical audio mixing technique. Although SClasses + Sound Class Mixes are not proprely side chaining, they do well the job. . At the end what happens is that all sounds routed to SClass_1 will tell SClass_2 to to lower the volume (and then up again when finished), the way happens is done via a SClass Sound Mix. Check unreal learning portal, there is a tutorial on .

Those are two separate issues, I was just responding to your specific question.

Music Issue:

For a complex multilevel game, you’re describing having a comprehensive music management module in your game. There is a lot more to it than starting and stopping sounds. There is gain control, fading out old music and fading in new, matching meter in some cases, stopping and starting on musical bars etc. I’m with you, it’s exactly what I am working on right now because with 5.0, my old methods are being deprecated. For topic, my opinion is you need something that is not attached to a death manager of some pawn directly, but that you can control from various events (from any type of pawn or controller) such as player dying, level changing, a boss appearing within the level, boss dying, spooky events etc. Unreal doesn’t provide , it’s something you have to develop and UE provides the tools.

If you are planning to release your game on 4.x, can be accomplished with Quartz, Sound Mixes and Sound Cues. It could be done in GameMode or GameInstance and things like your death management can trigger events when it wants a change. Similarly, when a boss fight starts, the event of that boss appearing would trigger events to fade out the old and start the new. There is an excellent series of videos in the learning portal on and I’d suggest running through that. It teaches how to start a Quartz clock and queue and stop your sounds in musical sync. You would have to add to changing what music you are playing with a scheme you develop to send triggers, probably events, to that.

On 5.0, things change so it depends on how quickly you will be done and release your game. In 5.0, the old ways are being deprecated (Sound Cues and Mixes) and replaced with MetaSounds and unfortunately something called Audio Modulation that has not been released (so I am ignoring it because it appears all can be done in a complex MetaSoundSource with MetaSound “subroutines”). My approach to doing is that GameInstance starts the music manager when the game is started. The music manager is a single MetaSoundSource that can receive triggers from any Actor and remains alive across all levels until the game is exited. Those triggers can switch between Idle and Combat versions of themes, or change to a completely new set of themes when necessary (level change, cut scene, loading screen, boss fight etc). It’s not done so I can’t show all the specifics of how I’m doing it.

Music Summary: I think you are suggesting you need something managing your music (versus just playing and stopping one-shot death music as you are right now and thread talks about) and the engine version you are releasing on will determine your approach. You have to create that manager or buy something called WWise or FMod which I know nothing about.

Death Logic Issue:

The only reason I mentioned that is because you were asking how to stop it when your player dies. If the level is restarting and you haven’t ticked the “persist across levels” boolean, your music will stop when the “new” level loads (the respawn). Thus I assumed you must be doing something else and the music was spanning the respawn. If so, you would need to use a class not tied to the player character to stop the music. That was all I was saying. I wasn’t saying that the death code not be in the character.

is OT, but I don’t see anything wrong with your death logic being contained in the player character at all. Different playable characters, AIs, vehicles may all benefit from having completely different death sequences even if they have shared code for efficiency. We do with our space flight vehicles, a giant battle cruiser may take minutes to die through series of explosions with individual sections flying off it, while a small fighter craft just blows up and leaves space junk. For dramatic effect, every vehicle type has it it’s own involved way of dying. Playable Characters and ground AIs can benefit from the same concept.

1 Like