Using Sound and Music

There are a couple of ways you can use sound in the Armory game engine and we will look at all of them now. First let’s start by playing a simple sound effect, in this case, a .WAV file. You can also use .OGG and .MP4 platforms, depending on the platform you are targeting. WAV is an ideal format for playing sound effects, while OGG is better for longer audio files, such as music or dialogs. First, we need to get a resource into our game. In the Armory properties, click Project Folder.

Armory3D Armory Project

This will open your local file system browser, such as Windows Explorer on Windows or Finder on Mac. Create a new folder called “Bundled” in this directory

Next, drop your .WAV file into this folder. If you need a source for .WAV files, try if you wish to download some,  or if you wish to make your own simple sound effects.

Let’s start with a Haxe example, create a node in the scene or use the default cube and attached the following trait/script to it:

package arm;

class SoundPlayer extends iron.Trait {
  public function new() {
    notifyOnUpdate(function() {

The code is pretty straight forward, in the update callback of our trait, we check to see if the ‘S’ key is pressed if it is we call getSound(), which takes two parameters. The first is the name of the sound file to load, the second is the callback function to call when the loading is done. Once the file is loaded we play it will a call to passing our newly loaded audio file.

Now let’s perform the exact same task using nodes instead. Before we continue, however, we are going to have to make the sound effect available in Armory. First, start by hitting Space Bar and typing open sound:

sound Armory3D

A file choosing dialog will now appear, select the sound file you just added to the Bundled folder. Next in the Outliner, switch to Data-Blocks mode:

data blocks mode Armory3D

Now scroll down and Sounds, expand it, and select your newly added sound, click the text box to the right of Fake User.

Armory3D sounds

Open the Node Editor, switch to game mode and create the following Node tree called “SoundPlayer”:

Armory3D Soundplayer

Now make sure that you create a trait, of type Nodes and attach your newly created node:

Armory3D Armory Traits

The final way you can play sound in Armory is by using the Speaker object in Blender. Select Add->Speaker in 3D View.

Speaker Object Armory3D

Now select the Speaker Icon in the Properties panel, drop down the Music note dialog and select the wav file.

Armory3D Speaker Icon

Now create the following node tree:

Armory3D node tree

In the Play Speaker node, be sure to select the newly created Speaker in Blender. The nice thing about using the Speaker node is you have detailed control over the way the audio is played such as the volume:

Armory3D Play Speaker Node

Like what you see?...pass it on!

Scroll to Top