How to Add Sound to your Game

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.

Screen Shot 2015-10-19 at 10.04.08 am

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.

Screen Shot 2015-10-19 at 10.06.45 am

Save your script, giving it a name and making sure that “The Music” variable has “Public” checked.

Screen Shot 2015-10-19 at 10.09.06 am

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;

 

Screen Shot 2015-10-19 at 10.20.40 am

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.”

Screen Shot 2015-10-19 at 10.27.36 am

Then select the music you want to play from the drop-down;

Screen Shot 2015-10-19 at 10.28.39 am

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!

 

10 Replies to “How to Add Sound to your Game”

    1. Worked out question I asked, I think it answers yours to. There variable of the sound isn’t public. Click the button in thescript editor left of the script title. There you will see the variables in the script and can set them to public. It will work then I think

  1. I did everything as mentioned… but the background music is isn’t playing for my game… I try it for an object its not working then i try it on the background but still remain the same no sound

      1. I am unable to hear the sounds I have added to my game. I have attempted it by following the steps and still no sound is audible. Please help! Thanks Gamefroot!

  2. it’s just not playing the sound, full stop. i triple checked that i did everything right, my only guess is that its a problem with the editor

Leave a Reply