Parameters are used in FMOD to manipulate your sound with game data from Unity. For example, you could create a Parameter which increases the pitch of a sound depending on how fast the GameObject it is attached to is moving.
Parameters are very powerful, have a look at the FMOD documentation to get a better idea of their potential uses.
In this guide we are going to create a Parameter which will change the pitch of a boulder sound depending on its Speed.
To create a Parameter select the Event you want to use it on and click the plus symbol next the ‘Timeline’ header, then click ‘Add Parameter Sheet – New Parameter’.
There are a few types of parameters but for this guide we’re going to create a Continuous Parameter called ‘Speed’ with a range of 0 to 50.
Now the Parameter sheet has been added to the Event we need to use it somewhere. In this example I have a 3D Event of looping boulder sound. The Spatializer has its ‘Min & Max Distance’ set to 5-50.
We want the pitch of the loop to adjust based upon the Speed Parameter we have created. Most settings in FMOD can be automated. The way to automate a setting usually is to right click it.
If we select the ‘Master’ track in the Event, you can see to the right side of the Spatializer the Event has various settings including ‘Pitch’. We can right click this Pitch parameter and click ‘Add Automation’.
This creates a new Automation Track on the Master track. We can use this to adjust the pitch of the whole Event. Navigate to the Speed Parameter Sheet and draw your automation onto the master track there. It should look something like this.
You can play your Event in FMOD and use the Speed slider at the top to preview its effect. Depending on the speed of your object you might need a more extreme pitch change than the one pictured above to hear it properly. Now your Event is ready for use in Unity. Make sure you assign it to a Bank and correctly build/assign the Banks then look at Using an FMOD Parameter in Unity.
To use a FMOD Parameter in your mod you need to code a custom script. For our boulder example, we need a script that sends a physics Rigidbody’s velocity to FMOD for our Event to use.
The script below will play our looping Event OnEnable and stop it OnDisable. Every physics update frame Unity will send the Rigidbody velocity to our FMOD Event.
Create a script with the above code and assign it to a Sphere with a Rigidbody. Then you can copy your Event path to the BallSound component.
Then build your mod and test it out. As you throw the ball around, its looping sound should change pitch!