I think i found a way. First delete those music classes you made and revert back to play sound at location but replace the play sound with spawn sound wherever you like. So basically undo everything i said before but replace play sound with spawn sound node.
1.) Create a boolean variable called stopmusic in you player character blueprint.
2.) Set that variable to true when the game is over.
3.) Now go to each blueprints that contain spawn sound at location nodes and cast to third person character and make a reference variable from that cast.
4.) Now wherever you have the spawn sound at location node, drag the return value of the node and search for stop.
5.) Then use an event tick to make a branch node and on the red pin of the branch node get the stopmusic variable from the reference variable.
6.) Now when the stopmusic variable is true then you take the execution pin of the true node and connect it to the stop node you created before.
Hey, sorry for the late reply. I have been busy the past two days.
So I tried this solution today and there was no luck sadly. I created an Actor that you show me in which did not work and when I had placed it on my level, it was playing the music instead of stopping. I had tried it with my Enemy Character and instead of stopping the music, it created multiple pieces of music as soon an Enemy was spawned.
That would work yes, but it would cause to have a slow process of loading to another level and waste memory usage. Unless I do a cutscene that is, however, my game will not work for this case.
If you are doing this in Blueprints, you will need to make a base C++ class to get access to this functionality, but then you could make a function you can call in the Blueprint.
Create another blueprint BP_SoundMute and place it somewhere on the map
Open it and create there a bool „b_SoundsIsMute“
Create a custom event „SoundMuteOnOff“ with flip-flop and set „b_SoundsIsMute“ on „A“ like False and on „B“ like a True
Open my parent pawn actor and set a new event on the keyboard input key „M“
„Get all actors of class“, „BP_SoundMute“, „get a copy“ and find the custom event „SoundMuteOnOff“
You can use this blueprint actor for 2 cases:
• cast from this bp to each actor in your scene to mute it (just add each new actor with sounds here)
• cast from each actor in the scene to check the bool (if something should be spawned muted)