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.