Repository navigation
FMod
Fmod is an audio management software, plugin and framework used for adaptive audio in games. With the use of parameters, FMod can change audio on the fly, or just play audio, acting as a replacement for Unity's built in audio system. For this project, we're using FMod Studio and the FMod for Unity package.
Fmod Studio is a DAW in which you define parameters and make events. It is separate from Unity, though the project's FMod user can link Unity with FMod for easier testing (This is discouraged as it can cause merge conflicts). Since FMod studio is it's own program in of itself, I recommend you follow the official tutorial video series if you wish to use it. It can be found here
Warning
In Unity, the FMod package has an option to change it's build path. By default, it will choose "FMod Studio". This will cause issues with revision control, so change it to "Multiple Builds", and change the directory to the FMod builds in your Unity asset directory.
- Events: Are used in the engine to play audio.
- Oneshot: A oneshot is an instance of audio that plays an event off once, or till loop, and then destroys itself. Basically a temporary instance.
- Instance: An instance of FMod audio. It will play until either the audio is complete, or when it is told to stop in a script.
- Parameter: A variable used to change FMod audio in some way. Can be changed in code.
To play a single instance of an FMod event, you need to call a "Oneshot". This does not need further referencing so it can be thrown really anywhere.
private void PlayAudio() { FMODUnity.RuntimeManager.PlayOneShot("event:/EventLocation"); }
Inside of the PlayOneShot, the parameter is a string of the directory path for the event. This can easily be gotten by:
- right clicking the event in Studio and clicking "Copy Path":

- Going to the event browser in Unity and clicking on "Get Full Path:

Instances are a bit more permanent. It's easier to edit any parameters on them and they're less likely to be lost than a OneShot. First you must define an Instance as a variable.
private FMOD.Studio.EventInstance _exampleInstance;
Then do this in a function to assign an event to it.
_exampleInstance = FMODUnity.RuntimeManager.CreateInstance("event:/ExampleEvent");
Then do this to play the instance.
_exampleInstance.start();
Stopping an instance can be tricky. You need to actually define how to stop the instance. For now, let's have it be immediate. Other methods can be found online.
_exampleInstance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
Editing a parameter is highly encouraged to only do to an FMod instance. Here's the line to edit an Instance's parameter
exampleInstance.setParameterByName("ParameterName", parameter_value);
Here, the "ParameterName" should be replaced with the Parameter name you want to edit. parameter_value is the given value. So if you need to set a parameter called "Angry" from 0 - 1 to change the music's state, you'd put in:
exampleInstance.setParameterByName("Angry", 1);