![]()
In this tutorial we’ll go over how to set background music and sound effects to our room.
- First off we have to see our new sounds and music in our assets section;
1<Assetid="bgMusic"url="[base.url]sounds/quest1/backgroundMusic.mp3"/>2<Assetid="bgSounds"url="[base.url]sounds/quest1/seagulls.mp3"/> - Then we need give our sounds some properties;
1<Soundstarget="{Room.player}">2<Soundid="backgroundMusic"assetID="bgMusic"play="true"looping="true"strength="1"bufferDuration="10"stereoWidth="0.8"/>3<Soundid="backgroundSounds"assetID="bgSounds"play="true"looping="true"strength="2"bufferDuration="10"x="600"y="100"carry="200"stereoWidth="0.8"/>4</Sounds>For each we set a different sound ID to tell them apart. Then we set their play value (whether they will play automatically when entering the room), the strength or volume of the sound, it’s buffer and it’s stereo width. If you’re not too sure about the last two you can leave the code out and they’ll work on default settings.
For our background sounds, we want it to radiate from a specific point in the room and get loader/quieter as our player moves towards/away from the source. To achieve this we set X/Y co-ordinate and a carry value, which is the distance in pixels from the source before it starts to fade out.