Blog: Game Audio Scripting With Unity - Part 1

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.




More From: UNITY
Even more news...

 



More Videos

Roland DJ808 - We Ask Questions 

Product Manager Nick provides answers


Cymru Beats 2016: Nick Batt Live Rig 

We get a look at what Nick uses live


Volca Vibes: RetroKits Solves Volca FM MIDI Velocity Issue 

Active MIDI cable has new firmware


Sonic LAB: Pittsburgh Modular Lifeforms SV-1 Blackbox Review 

Compact, desktop, analog, semi-modular - whats not to like?