Getting Started
Requirements:
- Wwise v2023.1.4.8496
- NOTE: If the version is not available to download you can try getting the closest version available to the number listed above, you can make sure if it is compatible or not is by checking what SchemaVersion and what SoundbankVersion you got in SoundbanksInfo.xml file after generating your soundbanks with Wwise. SoTV (DLC 1) version of RoR2 uses SchemaVersion 12 and SoundbankVersion 135. You can find game's SoundbanksInfo.xml inside Risk of Rain 2_Data\StreamingAssets\Audio\GeneratedSoundBanks\Windows.
- An IDE (like Visual Studio 2022)
- Audio files in .wav format (will not work in any other format, convert using audacity if needed)
Note: This tutorial will not showcase all the advanced features Wwise offers such as randomness, 3d audio, and other features. Only importing an audio and getting it to play via script.
Installing Wwise into a Unity Project
Follow the order exactly, deviation will lead to the project not being setup correctly.
The Wwise Installer does not function well when trying to install to an existing project, so it is recommended you start from a blank unity project to complete these steps. After completing all steps you can copy the content from the new Wwise project into your target project and should be able to open it successfully with wwise at that point.
- Get Offline Installer from AudioKinetic https://www.audiokinetic.com/library/edge/?source=InstallGuide&id=working_with_offline_installers
- Create new Unity Project with Unity Hub for Unity Version RoR2 uses
- Close Unity
- Open the Wwise Launcher and navigate to the Unity Page
- Find the new project in the list, and click on the left drop down to select the option for Integrating with an Offline Installer
- Wait for the Wwise Launcher to finish the integration process
- Open the Project with Unity again
Remaining steps are only for ThunderKit users
- Backup your project before starting so you don't have to reintegrate Wwise in case Thunderkit fails to do its thing.
- Create an Assembly Definition in the Assets/Wwise folder and name it Wwise
- Create an Assembly Definition in the Assets/Wwise/Editor folder and name it WwiseEditor
- Install ThunderKit
- Install RoR2ImportExtensions
- Locate Risk of Rain 2 using the ThunderKit Settings window
- Wait for import to finish.
- Delete Packages/Risk of Rain 2/Wwise.dll if it exists (.dll will not be visible in the name in Unity)
- Delete Packages/Risk of Rain 2/plugins/AkSoundEngine.dll if it exists (.dll will not be visible in the name in Unity)
- Delete Packages/Risk of Rain 2/plugins/AkWaapiClient.dll if it exists (.dll will not be visible in the name in Unity)
However, there is a chance that your import will get stuck (as in stops progressing), it is caused by conflicts between Wwise and Thunderkit. To solve this do the following steps:
- Delete both assembly definitions created on steps 9 and 10 and restart import process. Your best bet is to restore the backup that you surely made and start from step 11, ignoring 9 and 10 for now.
- After Thunderkit does its thing you will get error messages described in steps 15 to 17. Ignore them for now.
- Go to Assets\Wwise and create Assembly Definition called Wwise, under Assembly Definition Reference add Unity.Timeline, click Apply.
- Go to Assets\Wwise\Editor, create Assembly Definition called WwiseEditor, under Assembly Definition References add Unity.Timeline and Wwise, under Platforms uncheck "Any Platform", click Deselect all and check "Editor" (this is important, otherwise Thunderkit will attempt to compile editor scripts into assembly, resulting in errors), click Apply.
- After this you will still get errors from steps 15 to 17, do those steps to fix the errors. You might need to restart the project after deleting dlls.
After doing all of this you should have a successful integration of Wwise and Thunderkit into your project. The easiest way to check whether integration was successful or not is to create MusicTrackDef (Create - RoR2 - MusicTrackDef) and if it looks like this
Then you did everything correctly. However if it looks like this
then you messed up somewhere and have to retrace your steps.
Process:
The Whole process in video format up to the coding part.
- Launch wwise and create / open project.
- To import a new audio, use Project > Import Audio Files > Select your audio file and hit import. After importing it should appear in the hierarchy as seen below.
- Next we're going to create an event that will be used to call this sound from script.
- At the top hit Layouts > SoundBank
- Now at the bottom left you should see an event viewer, right click inside and create a New Event > Play
- Name it anything and hit okay, now in the target field you will select the audio clip you imported earlier by dragging it into the field.
- Now that we have our event setup for our audio clip, we can create our soundbank. In the upper right window (SoundBank Manager) you can hit new and create your soundbank.
- Now with your soundbank selected, you can drag your event into the soundbank editor to add it to your soundbank.
- Now just hit Generate Selected and it will generate your soundbank.bnk file!
Playing your audioclips from script:
Check how to import a soundbank here
* Now to finally get a sound to play, just call
AkSoundEngine.PostEvent(