Audio System

Overview

The audio system in Guncaster evolved from a simple sound playback manager into a robust, gameplay-reactive system. What started as basic functionality for 2D/3D SFX and music playback grew into a dynamic, efficient, and highly customizable toolset that enriched the player experience and improved performance.

Details

The original audio system in Guncaster was a simple manager that handled basic sound playback in 2D/3D space and supported background music with dynamic combat transitions. It worked, but it lacked flexibility, performance optimization, and depth. In the final stretch of development, I completely rebuilt it into a far more powerful and responsive system

The new audio system is built on Unity's IObjectPool, ensuring that sounds are efficiently reused instead of constantly created and destroyed at runtime.

At its core, it uses ScriptableObjects to define and assign sound configurations across gameplay elements. configurations could control looping behavior, pitch variance, falloff distance, and the target mixer group for fine-tuned audio routing.

Additional performance enhancements included the introduction of frequent sounds and single sounds. Single sounds prevented overlapping by allowing only one instance in the scene at a time (useful for UI), and Frequent sounds, which use a queue system to limit how many can play at once, reducing audio spam and preserving clarity.

Mixer groups are fully integrated, giving players volume control over different sound types via in-game settings. A global master slider controls overall volume, while additional sliders handle SFX, music, and ambient layers separately.

The cherry on top for fun and interactive sounds was my introduction of dynamic pitch. To push immersion further, all audio pitch was tied to the game’s Time.timeScale. When time slows down for a punch or during menu transitions, sound pitch shifts in real-time with it, creating a cohesive and cinematic experience.

Give a listen

Features

  • Audio Pooling and optimized playback using Unity’s IObjectPool

  • Volume sliders per sound category + global master

  • Combat and ambient tracks blend based on game state

  • Scriptable objects for sounds to Configure pitch, loop, mixer group, and falloff

  • Pitch variance to repeated sounds

  • Audio pitch changes with time scale

  • Sound Playback Control:

    • Single: One instance allowed at a time

    • Frequent: Queued to prevent sound spam

Comparison

Iteration 1:

  • Manual sound playback (2D, 3D, BGM)

  • Simple manager class

  • Basic dynamic music fading

Iteration 2:

  • Fully pooled audio via IObjectPool

  • ScriptableObject-driven sound profiles

  • Mixer group support with exposed controls

  • Time-scale reactive pitch shifting

  • Sound limits via single/frequent categories