Lining up Audio & Visual to Build Cutscenes in Unity
Nothing brings a cinematic cutscene to life quite like audio. Without audio assets, the cutscene is basically a silent film. In this article, I will be adding music and dialogue to a cutscene that will act as the intro to a game.
In the spirit of keeping the hierarchy organized and free of excess clutter, I make a new empty game object to act as the parent folder for the music and dialogue, and rename it to be Audio. I create two more empty game objects and place them inside the Audio folder. One object is titled Voice Over, and the other is named BG Music.
Both objects for the Voice Over and Background Music have an Audio Source component added.
Now in Timeline, a new Audio Track is added.
This Audio track is renamed to Voice Over, and then the Voice Over dialogue file is dragged from the Project folder into Timeline.
Another audio track is added to Timeline, and then renamed to BG Music. The audio file for the background music is dragged into the Timeline from the Project folder.
In an effort to stay organized, a new group is made in Timeline and titled Audio. The Voice Over and Background Music Audio Tracks are dragged into the new group.
One downside to Timeline, at least for this version of Unity as I write, is that you can not preview the Audio in Timeline like you can the virtual cameras. (Newer versions of Unity do have an option in the Timeline gear icon drop-down to Enable Audio Scrubbing.) However, If you press the play button at the top of the screen to run the game, the Audio tracks will play as expected. While in play mode, you can pause the game and scrub to a new location in Timeline for previewing, and unpausing the game will play the audio and visual from that designated point. Another important thing to note, is that changes in Timeline will save even when the game is playing. Typically nothing saves while in play mode in Unity, so this does seem like a special situation. This can come in handy because it enables the user to scrub through the audio and virtual cameras in play mode, make edits and have them save. This way is really easy to adjust the camera cuts to match the audio tracks. I am working with one long audio track here, but even smaller audio clips can be added and adjusted with ease in play mode.
I hope you enjoyed this article on using Timeline to sync up audio and visual elements in Unity. Now that all of my cutscenes have been made, I can start coding this game in my next article. Thanks for reading!