There’s a fantastic new feature in our editor, it’s an asset of the audible nature: it’s sound and music! We’ve had the code blocks for some time, but no way to add your own sounds, but now that’s all possible. Let me talk you through it.
The first thing you need is a script to trigger the sound to play. Click on “Add new” in the scripts panel.
Next you’ll need to write your script; use the code blocks to create the image below. This script simply plays some music when the object the script is attached to is created.
Save your script, giving it a name and making sure that “The Music” variable has “Public” checked.
Now we’ve got our script, we need some music to play. Open the “Asset Manager” by clicking on “Assets” in the top right of the screen (next to preview). Create a new pack or select one you own and click the “Create New Asset” button. Select “sound/audio” and upload the music you want to use. Here’s a track to get you started;
Once your tracks are uploaded, the only thing left to do is add them to your level! Add a new game object and attach the “Play Music” script to it. Now right click the object and select “Edit Instance Properties.”
Then select the music you want to play from the drop-down;
And that’s it! You’re all set. Hit preview and enjoy the sweet serenade of you’re in-game music. Why not give some sounds a go now? It works the exact same way, the only difference is that multiple “Play Sound” blocks can be played over top of other sounds and the sounds you play wont loop like they do with music. Good luck Gamefrooters!