Defining Different Footstep Sounds
In Unity and Wwise
With our footstep Wwise Events being triggered through animation — read more here — we now need to create a system to define what footstep sound effect should play. In our game we have two different materials, carpet and marble, so we need two unique sounds. In Wwise, we can easily set up a Switch Container to control this, but how do we go about defining which Switch should be triggered.
To start with, I know that I want to call the changes when the Player enters different areas of the level. This can be achieved with Box Colliders set to Is Trigger.
With each of these colliders, I want one modular script to handle the Switch change with any material I may choose. Therefore, if I wanted to expand the game and have for example, an outdoor mission, I could attach this script to another collider and pick the grass switch.
Using SerializeField, the Switch material can be defined in the Inspector. Then using a Property, we can create a handle to get the variable, making sure the set is private, so only this script can define it in void Start.
With a way to access each collider’s material, we can now add to the Footstep Poster script attached to the Player.
As this script is attached to the Player, we can come across a lot of different Trigger Collisions, therefore we need to create a tag for our floor material colliders.
With this defined, we can grab a handle on the colliders script, and thus the public Material we created. Now we can use SetSwitch, to change our Footstep_Material Switch Group to our defined Switch.
Using the Wwise Profiler, we can now see our different colliders alter the Switch Container.