Background music in area

I know how to set up bg music across entire level with sound cue, but I want only one general bg music (world theme) and then several localized bg themes in specific area (i.e. city)

  1. How can I play bg music in specific area only? (and subsequently how to ensure transition between theme for the whole map (world theme))
  2. How to “set-up” local bg music which is inactive, activated by blueprint (i.e. tension theme playing only when something happened)

Thanks

You can accomplish this by creating two Audio components on your PlayerController. One is for the overall map background music and the other Audio component is for a localized area. My design below allows only map-wide background music plus one additional “localized” music. This should get you moving along quickly and you can amend this solution to work better for your requirements

  1. Open your PlayerController. Add two new Audio components, one for the map’s BG music and the other for the localized area BG music. We’ll name these MapBackgroundMusic and LocalizedAreaBackgroundMusic respectively.

Go to the MapBackgroundMusic details and specify an audio file to play and check Auto Activate under Activation. Auto Activate means the music will automatically start playing, if it’s set to false you will have to manually turn on the music.

With that being said go to the LocalizedAreaBackgroundMusic details and set the Sound file to “None” and turn off Auto Activation. We don’t want to automatically play this sound, we want our triggers we created to turn trigger this audio.

  1. In your PlayerController add the events below. The Sound parameters we are passing around are of type “Sound Base”. PlayLocalizedSoundOnClient and StopLocalizedSoundOnClient are replicated events that are set to Run On Owning Client and reliable.

StartLocalizedSound and StopLocalizedSound are events that are called on the Authority (for networking) and they are called by our LocalizedBackgroundMusicTrigger blueprint that each of our custom background music triggers inherit from.

  1. Create a new blueprint that inherits from SphereTrigger. Name this blueprint LocalizedBackgroundMusicTrigger. Create a class variable called “BackgroundMusic” of type “Sound Base” with a default value of None. Fill in the OnActorBeginOverlap and OnActorEndOverlap events like I have.

  1. Create a new blueprint and give it a descriptive name. I named mine FireMusicTriggerSphere. Open this new blueprint and click on the eyeball drop down and check “show inherited variables”. Locate the “BackgroundMusic” variable in our FireMusicTriggerSphere class (this variable is inherited from LocalizedBackgroundMusicTrigger). Set the default value of this variable to what you want, mine is set to Fire01 from the starter content.

Compile, save and close this blueprint, we’re done with it. Repeat this step for each unique song you want to play in your map.

  1. Now you can drag and drop the music triggers that you want in your map and resize/move them until the triggers encapsulates your localized areas.

Hope this helped.

1 Like

I forgot to mention, if you look at my first image where you create the Audio components (https://answers.unrealengine.com/storage/temp/118741-screenshot_121416_053132_pm.jpg) notice the “Volume Multiplier” options in the details.

You can increase/decrease this to increase and decrease the sound/song respectively. As you can see in that image I reduced this to 0.25 so the map-wide BG music is lower volume than the localized areas.

If you would like to have a smooth transition between map-wide and localized BG music you will have to use a timeline to adjust the Volume Multiplier over time.

Example of a simple transition is below.

1 Like

Was hoping there would be easier solution, but thanks for the detailed answer