Playing voice files

Adding voice audio when characters speak can greatly increase your game's immersion. Each line can either have an audio file manually associated with it (or multiple, if your game supports spoken translations), but they can also be associated automatically through naming convention.

For a character to play speech audio, they must have an AudioSource component. This is a simple matter of finding their prefab, clicking Add Component, and selecting Audio Source.

Note: If this is added to a child object, and not the root object, then you must also assign it to the character's Speech AudioSource field.

Next, your speech lines must all be given unique ID numbers to identify them. Before this can happen, you must make sure that every scene in your game is added to the Build Settings.

To add a scene to the Build Settings, first open the scene and choose File -> Build Settings from the top toolbar.

Then click Add current to add it to the list of Scenes in build.

When you have done this for all of your scenes, navigate to the Speech Manager in Adventure Creator's Game Editor window. To rely on the naming-convention method, check Auto-name speech files? under the Speech audio section:

Underneath the Speech lines heading, click Gather text. Adventure Creator will search your game for displayed text, and list it beneath.

The number to the left of each line is it's ID number. To create a file that lists just your speech text, click Create script sheet..., and you will be prompted to save a script file.

The lines will be grouped by the scene in which they appear, and also display the filename the associated audio file must have. Audio files can take any audio format that Unity natively understands, such as mp3 and ogg. For example, the first line shown above can have an audio file of either Player2.mp3 or Player2.ogg.

Once you have created your audio files, you need to place them within a subfolder called Speech, within a folder called Resources. Note that the location of this Resources folder is not important: /Assets/My Game/Resources/Speech is as valid a filepath as /Assets/Resources/Speech.

If your game's text is available in multiple languages, you may also want your speech audio to play in multiple languages. The filenames of translated audio are the same as the originals, only they must be placed in a subfolder of the same name as their language. For example, a French translation of the Player2 line must be placed in /Assets/Resources/Speech/French.

For more on creating translations in your game, read this tutorial.

Adventure Creator and this website are copyright Chris Burton, ICEBOX Studios

Go to top
Do NOT follow this link or you will be banned from the site!