Welcome to the third of final part of the audio tutorial. We’ll add music to our map. On our example map we’ll set three different types of music. Global, playing automatically on the whole map. Ambient, building atmosphere after going into the tunnel. And finally an action piece, playing when fighting a Goon. Let’s start with defining the global music track. On the top of the Objects list we select our Level. We go to Attributes window and select ‘Fields’ tab.

We set the music in n_MusicPreset field. Let’s open the list of available presets and select one of them, for example default_02 Default presets are specifically prepared to play globally on open area maps. They consist of a lot of short music themes played randomly, with intervals. The music we set will be played across the whole level, but we often want it to change depending on situation or location. In those cases, we use MusicArea object. The sound played by this object is attributed to ‘music’ group, which is different than in AmbientZone, which has its own group. Because of that you can control the sounds’ volume specifically from the game’s menu. Let’s use Music Area object to set ambient music in the tunnel.

In the Assets window let’s find Music Area object and place it on the map. The new box can get easily confused with earlier Ambient Zone boxes, so let’s hide them for the time being. In Objects we select any AmbiendZone, right-click it and select ‘hide same class’. Let’s get back to the music area. Music will be played only within the specified area. And will override the global settings. Let’s move it the tunnel and scale it to encompass its geometry.

Now we can set what kind of music we want to play in this area. Let’s open Attributes and open the list in m_MusicPreset. Let’s select one of the pieces of ambience music, for example ambience_03 We can check if we like the preset by selecting the flag in Play field Now we have ambience music ready, but we want dynamic music to play when fighting a goon, which will fade after killing the enemy. The easiest way is to place another MusicArea in the space the combat will be happening. In case of overlapping music areas, there will always be only one track playing – the last one the player entered will override any previous, overlapping areas.

Let’s put in and rescale another MusicArea and name it. Like before, we’ll select a fitting preset, for example attack_goon_01 Let’s see how it works in game. Ok, the music plays correctly, but the dynamic action music doesn’t stop after Goon dies. Let’s correct this. We’ll connect a spawner to Music Area. Thanks to this, the Music Area will only be active when the connected spawner (or spawners) is active. Let’s go to our Musica Area, Music_Goon_Fight In Attributes window, we right-click m_Spawnboxes and we select Insert references to objects. Let’s remember the spawner and music area can only be joined if they are withing the same group. We add the Goon spawner to Music Area. Let’s check if this time the music will stop after the death of the enemy. Ok. Now everything works as intended. And that’s it for our sound tutorials. Thanks so much for tuning in..

As found on Youtube