As described in the video add the player transform, create & add the obstacle layer and similarly an FMOD parameter. The other settings are optional and will be discussed in more detail below.
as “Param Distance Max” and the sound will be from that distance. As the spatialiser has a distance attenuation you can set the value a bit higher than the script setting or change the roll-off param on the plugin.
is discreet so we’ll need to use the seek speed setting to smoothen the transition between off/on. As FMOD currently doesn’t include this option for “discreet or labelled” parameters we need to create the parameter for the “switch” between occluded and non-occluded sound as a “continuous” param. An FMOD forum thread about this is here
In my video example, I’m only setting the seek speed in one direction. Still, it’s certainly useful to use the asymmetric functionality and have the sound appear “slower” on entering the non-occluded area but on exit have a more rapid return to the occluded sound. As “Velocity” increases the param value continuously I don’t think it’s useful in this scenario
Setting up AMBIENCE FX
Delays Go To Section
For ambience FX such as delays and possible reverbs Read More
we’ll use the “FMOD Param Fade” setting. This is a “continuous” parameter which takes its value from the “Scaled Val Depth” at the bottom of the script in the inspector. This value is a normalised value (0 – 1) of the “Param Distance Max”. Normalised values are super useful as we only have to change the distance param in the script and the FMOD values will adapt automatically – so no need to scale from one value to another.
It does make setting up the automation slightly more granular as there can be quite a difference in effect between small number distances e.g., 0.85 -> 0.9 for this reason it’s helpful to use the automation lanes in FMOD rather than the Deck option which is quite small, especially on a laptop. For tweaking these values I recommend using FMOD Live Update
OPTional reverbs
Reverb settings Go To Section
The script includes discreet enum values that can be used to set a parameter on start.Read More
This could be reverb types for materials either algorithmic or convolution (although expensive). As this is discreet with no range it’s useful to add this as a labelled parameter in FMOD. The Unity options will of course remain what they are but you can use this for other things than reverbs. Just adding an EQ setting for each value on a reverb send can be a quick and easy way to change the “environment” for that effect e.g., stone to wood using high and lowcut changes.
The script
Note: This script is set up so you need to add objects manually in the Inspector – it might be worth considering adding the objects automatically on start if used in a bigger project.
on a single raycast set at half the distance up from the ground so it can detect “holes” in objects i.e., openings that should let the sound through. It takes the point from the transform where the script is and uses a layer to assign objects as obstacles. The “hitDistance” var is used to check if the object is between the transform and the player so we don’t set the obstructed bool on both sides of our walls or whatever is used as occluding objects.
The “width” var is currently not used specifically but could potentially be used to determine the “thickness” and “width” of the occluding object and then be used to procedurally set EQ values or similar in FMOD. However, I came across issues with trying to determine which side is used for the depth of the object so for now I’m just keeping it as is.
The value is normalised so we can set different ranges in the Inspector without having to make changes to the FMOD session. This “ranging” also allows the value to be used in either direction i.e., 0 <-> 1 but then that changes where the event would start so for FMOD create instance we’re using valToStartEvent which takes the same values but remains o to 1.
The rest of the script and the various statements just set where the “obstruction” is false although the bool isn’t used for any particular purpose other than debugging. But as the statements are not attached to the FMOD logic you can simply change the code if you want to use the script for Wwise instead e.g. AK.Wise.Event “myEvent’, etc.
The enums give us a set of ints at the start of play. I toyed with the idea of setting up a conversion from strings so the sure could apply their own terminology for the labels but it just adds needless complexity to the script.
adds “AttachInstanceToGameObject” to the script so the sound follows the moving source. It’s useful to add a rigidbody to the moving object to increase precision. Nothing really special here although this allows FMOD events to move around rather than the usual “PlayOneShot.Attached”
Leave a Reply