Skip to main content
Site Icon Mysterious Pixel

Event Audio for Godot

Event Audio for Godot

Some time ago I wrote a small add-on for Unity called UberAudio. Unfortunate title aside – ride-sharing wasn’t a big thing back then – it was a simple tool designed to make it easier to add audio to games, based on the system we used in both Dungeon Keeper and Fable.

Since moving some of my personal development focus towards Godot I found myself missing it.

So, here is Event Audio github repo for Godot. (Yes, still a shit title. But better than Uber.)


Basic Workflow

It works as follows:

  1. Build an Event bank, which maps ‘audio event’ trigger strings to audio assets.
    An image of the audio bank editor.

  2. Mount the event bank in your scene somehow. There’s a helper node to do this, or you can do it programmatically.
    Mounting Audio Banks

  3. In game, trigger audio events wherever you think audio things will happen.

    # 2D example
    EventAudio.play_2d("hit", thing_playing_audio)
    
    # 3D example
    EventAudio.play_3d("hit", thing_playing_audio)

    In this example, the thing_playing_audio is the node that the audio is associated with.

  4. In many cases, that’s largely it, which is the intention – most audio should be ‘fire-and-forget’.


Additional Details

Trigger Lookups

A key feature of Event Audio is that trigger strings are structured hierarchically with the separator character +. When and event is triggered, Event Audio will look for a match by incrementally dropping sections of the event string until it finds a match, or runs out of sections.

An example to make this clearer, from the example bank shown above:

In this case:

The purpose behind this is to allow arbitrary specialisation of audio events, while building up good defaults. For example, you could compose hit events programatically out of hit+<weapon_type>+<entity_name>+<strength>. This would result in hit events like hit+sword+goblin+hard, hit+mace+balverine+light. Initially you might only map hit, and as polish is added more specialised mappings can be added to the bank – without any code changes.

Other features


Finishing up

Game audio is such a vital part of the experience, but adding it is often fiddly enough that it’s left to the last moment. The easier you can make it, the earlier you add it; I find fire-and-forget audio triggering makes it much easier.

As always, I’ve made this plugin primarily for my own use, but hope someone else finds it useful.

I’m using it in my projects, but it’s fairly new – so if you hit any issues, let me know.

Simon