Voiceover Event Calls in Unity
Previously, all voiceover calls in our game were being called independently on either trigger objects, or from the Timeline editor in our cutscenes. Much like the Music system discussed here, I wanted to make a more modular system.
In Wwise, I have a selection of different SFX Objects containing each Voiceover sound, with corresponding Events. One of these, is actually a Random Container, that allows for different variations to be played for the same Event.
Over in Unity, within our Audio Manager Script, we have a public method that receives a Wwise Event type variable, then simply Posts it.
To call this, we can create a VOTrigger Script, much like our Music System, we can create different bools to discern how each Voiceover is to be called. The difference here, being that we select an Event as opposed to a Switch.
Now, for each possibility, we can check the bool, then call our Audio Manager’s method.
With use of Colliders, we can easily create Trigger areas in Unity, select the correct bool and Event, and we have a working Voiceover system.
For Voiceovers within Cutscenes, we can instead use the OnStart bool, and attach the script to that game object.
Taking things further, we can also skip our Voiceover Event. Some cutscenes are skippable, and we need the Voiceover to follow suit.
This script, can be added to our cutscene object, and simply grab a reference to the Playable Director so we can then grab the total time of the cutscene, and set the current time to be at the end.
In terms of the audio, if we look back at our VOTrigger script, you may notice the Event is an Internal type variable. This acts similarly to a private variable but can be accessed from scripts on the same game object. Now within our SkipCutscene script, we can get a reference to what the called voiceover Event is, and pass it on to our Audio Manager.
Within our Audio Manager, we can then call the Stop function on this particular Event.