Blog: Game Audio Scripting With Unity - Part 1

US Game audio development platform revealed      03/03/14

Blog: Game Audio Scripting With Unity - Part 1


Adam Mclellan Writes:

I'm going to take a big departure in the next couple posts to talk about my other passion outside of computer music: game audio. Specifically, I'll be talking about the basics of integrating and scripting audio in Unity. For those who don't know, Unity is an excellent cross-platform game development engine which also boasts a feature-rich free version. 

If you've ever wanted to get involved with game audio but weren't sure where to start, picking up some Unity skills is a sure-fire way to find yourself some work. While some sound designers would stop at asset creation and hand off to somebody more technical to integrate, I say why not go the extra mile? There are many musicians and sound designers vying for a very finite amount of work in this space, and if you're able to not only create audio assets but also integrate them you'll be able to sell yourself that much more easily.

And fear not: if you've ever worked with Max/MaxForLive, Quartz Composer, etc. then you'll have no problem picking up Unity. Tthe amount of actual "scripting" required to integrate audio is generally quite minimal--just a few lines here and there.

In this month's post I'll start by introducing Unity and walking through some simple scenarios, like importing sounds and triggering them. Next month I'll explore more complex topics like reverb zones and scripting dynamic audio events.

Unity 101
First let's start with some basic terminology stuff:
  • Scene: everything starts with a scene. Think of a scene as a level. It could be a room, an outdoor environment, or something more abstract like a menu screen.
  • GameObject: a Scene is made up of GameObjects. A GameObject is simply a container to store Components--anything ranging from a Camera to a Light to an Audio Source. Important to note is that a GameObject can contain other GameObjects (which can in turn contain other GameObjects, and so on.)
  • Hierarchy: the Hierarchy displays all GameObjects in the current Scene.
  • Assets: An Asset is any custom-created or third-party asset used by your game--textures, models, scripts, and of course audio assets. You can view Assets from the Project view. Assets can be organized in folders and named any way you'd like, but if you're dealing with many assets it's important to give this some thought. For example, you may want to organize by type (sound effects vs music vs ambience), by level/scene, or both.
Components
The types of Components we'll be dealing with for audio are:
  • Audio Listener: think of the Audio Listener as the player's ears. You should only ever have one Audio Listener in a Scene, and generally it will be on the same GameObject as the Camera component (the Camera being the players "eyes", in the case of a first-person game.)
  • Audio Source: Audio Source does what it says on the tin.
  • Script: A script allows you to script behaviour of a GameObject or its contained components (or technically, anything in the Scene, but we'll start simple.) Scripts can be created in C#, Java Script or Boo. We'll be using C# today.
Send us your News: If you have a story or product you'd like us to cover - email news@sonicstate.com or use our contact form or join our Discord and post in #cool-finds




Get the latest headlines, offers and more in our fly sonicstate newsletter - delivered to your in box every week

More From: UNITY
Even more news...


 

Get Our Newsletter


More...

SonicLAB: Genki Katla With Venus Theory 

We look at the volcanic synth


Lifeforms SV-2 - Pittsburgh Modular's Redesigned Semi-Modular 

SV-1 successor with thru-zero FM


SonicLAB: Pittsburgh Modular Lifeforms SV-2 

Classy analogue synth reviewed


AmiGUS mini: 24-bit Sound for Amiga 1200 & 600 

32 Channel PCMCIA Soundcard in Beta


SonicLAB: Lambda Synthetics Polypulse 

Algorithmic Performance Workstation


Will Vintage Gear become Liquidated E-Waste? 

Geopolitics, CRTs, Antique Computers & Vintage Synths