Behind the Scenes: Considering Triage’s Audio Solution

For Triage, we wanted our audio system to be responsive to what the player was doing. While we never formulated our intended system, I think that sharing the design for it will encourage others to think of ways they can make our idea work in their games.

Our system had two requirements, gurneys needed to make sounds when colliding with walls and making a movement sound that increases in volume the faster the gurneys move (to a degree). Triage also needed looping background music, easily made using a default AudioSource component.

Designing the Gurney Sound System


As above, the movement sound effect will be a looping effect that increases in volume the faster a gurney moves. Because they gurneys are physics objects, they may be moving constantly, so the curve for which the volume changes will need to account for periods of limited and maximum volume with some extra speed to spare:

In this semi-terrible graph, you can see that after a specified amount of time, the audio will ramp up, and cut off at a point before getting too loud.

Pseudocode Example:

Public float maxSpeed;
Public float currentSpeed;
Public float currentVolume;
Public AnimationCurve volumeCurve;

Void Update()

   // Normalise the currentSpeed of the gurney
   normalizedSpeed = currentSpeed / maxSpeed;

   // Set the audio volume to the correct point in the volumeCurve
   currentVolume = volumeCurve.Evaluate(NormalizedSpeed);

Here, an AnimationCurve determines the appropriate volume over a period of time. Using the ‘Time’ variable within the Animation curve, I can set the correct volume for the correct speed.

The collision system needs to collide with walls, but must not spam collision sounds when sliding against a wall:

Pseudocode Example:

Public AudioClip collision;
Public bool hasCollided = false;
Public float bufferTime;
Public float bufferComplete;

Void OnCollisionEnter(collision other)
   if(other.collider.GameObject.tag == “Wall” && hasCollided == false)
      bufferComplete = bufferTime + Time.timeSinceLevelLoad;


Void Update()
   if(hasCollided  = true && Time.timeSinceLevelLoad > bufferComplete)
      hasCollided = false;

Here, the sound will only play if it has hit a wall (tagged as “wall”) and has waited the appropriate amount of time before returning to its original state.

While not implemented due to bugs and time constraints, considering how to implement such an audio system is helpful to see the ways in which Unity empowers developers to use elaborate solutions to their problems.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s