Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Sounds for parts with Wwise and Unity: Difference between revisions

From Kerbal Space Program 2 Modding Wiki
Spacewarp>JiMKesa
No edit summary
m 9 revisions imported
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<nowiki>[[Category:Parts modding]]</nowiki>
[[Category:Parts modding]]


= Sounds for parts with Wwise and Unity =
= Sounds for parts with Wwise and Unity =
First, install your Unity environment, SpaceWarp template, ....
First, install your Unity environment, SpaceWarp template, ...


There are already excellent tutorials that explain these steps:
There are already excellent tutorials that explain these steps:
Line 10: Line 10:
[[:Category:Getting started]]
[[:Category:Getting started]]


=== First step: Wwise ===
=== First step: Wwise installation ===
You need to create an account : https://www.audiokinetic.com/fr/products/wwise/
You need to create an account : https://www.audiokinetic.com/fr/products/wwise/
[[File:2024-02-09 16 13 04-Wwise Audiokinetic.png|center|thumb]]Next : Install Wwise Launcher
[[File:2024-02-09 16 13 04-Wwise Audiokinetic.png|center|thumb]]Next : Install Wwise Launcher
Line 128: Line 128:
[[File:2024-02-10 06 28 21-kesa.Unity - Default - Windows, Mac, Linux - Unity 2022.3.5f1 DX11 .png|center|thumb]]
[[File:2024-02-10 06 28 21-kesa.Unity - Default - Windows, Mac, Linux - Unity 2022.3.5f1 DX11 .png|center|thumb]]


For Rtpc mapping, I’ve created AllRTPC:
[[File:2024-02-10 06 34 51-kesa.Unity - Default - Windows, Mac, Linux - Unity 2022.3.5f1 DX11 .png|center|thumb]]
And for your engine audio :
[[File:2024-02-10 06 28 59-kesa.Unity - Default - Windows, Mac, Linux - Unity 2022.3.5f1 DX11 .png|center|thumb]]
I’ve select 2 events for playing and stopping my engine sound : engine3_play & engine3_stop


That’s all. Now your engine will have sound !!!


==== Example 2 : sound in animation ====
For this example, I will show a solar panel with animations for deploying and retracting.


First, I create an empty gameobject u_amb_audio_solar_arrays
[[File:2024-02-10 09 13 08-kesasolar.Unity - Default - Windows, Mac, Linux - Unity 2022.3.5f1 DX11 .png|center|thumb]]
I've add components on it :
[[File:2024-02-10 07 05 11-Kesa solar - Wwise 2021.1.13.png|center|thumb]]
'''In Rigidbody, check "Is Kinematic" and uncheck "Use Gravity" !'''


On the gameobject with Animator component :
[[File:2024-02-10 07 10 51-Kesa solar - Wwise 2021.1.13.png|center|thumb]]
Drag & drop your u_amb_audio_solar_arrays gameobject in Animation Events Object field.


Then, we can set audio in animations, on deploying and retracting.


On the first timeline, in your animation windows, on the first frame, right clic :
[[File:2024-02-10 07 14 49-Animation.png|center|thumb]]
And set in Inspector :
[[File:2024-02-10 07 15 36-Kesa solar - Wwise 2021.1.13.png|center|thumb]]
Same action for the last animation frame :
[[File:2024-02-10 07 16 29-Kesa solar - Wwise 2021.1.13.png|center|thumb]]
Now, my animation has 2 audio events (white rectangles), in the first frame to start the sound, in the last frame to stop it :
[[File:2024-02-10 07 17 23-Animation.png|center|thumb]]
Animations can have multiples sound events :
[[File:2024-02-10 07 18 54-Animation.png|center|thumb]]
That’s all, now your part has sounds.


You know as much as I do now. I hope this tutorial will help you.


 
Don't hesitate to provide feedback, corrections, ... I don't have the knowledge :-)
 
END

Latest revision as of 17:46, 9 October 2024


Sounds for parts with Wwise and Unity[edit | edit source]

First, install your Unity environment, SpaceWarp template, ...

There are already excellent tutorials that explain these steps:

https://github.com/SpaceWarpDev/SpaceWarp.Template

Category:Getting started

First step: Wwise installation[edit | edit source]

You need to create an account : https://www.audiokinetic.com/fr/products/wwise/

File:2024-02-09 16 13 04-Wwise Audiokinetic.png

Next : Install Wwise Launcher

File:2024-02-09 16 15 29-Wwise Audiokinetic.png

Wwise is free for a 200 sounds databank.


Ok, now a warning : When I started my mod, I couldn't get the sound to work with the latest 2023 version of Wwise.

So I continued to use version 2021 of Wwise to prepare my sounds and I integrated version 2023 of the Wwise libraries into Unity for maximum compatibility.

So I will explain how I did it but maybe you can try directly with the latest 2023 versions. If you succeed, let me know so that I can modify this tutorial.

So, this tutorial will first install version 2021 to be able to have a Wwise project in 2021 format then I update the Wwise libraries in Unity in 2023 format.


For these reasons, here are the versions of Wwise on my computer:

File:2024-02-09 16 17 46-Audiokinetic Launcher.png

Ok, now let's prepare the environment for Unity. Wwise normaly will found your existing projects. We'll integrate Wwise on projects now :

File:2024-02-09 16 24 33-Audiokinetic Launcher.png

Next, select Wwise version (2021.1.13.8036 for me) and plateform(s) you want :

File:2024-02-09 16 33 22-Audiokinetic Launcher.png

If some packages are missions for destination plateform(s), this message will appear :

File:2024-02-09 16 34 07-Audiokinetic Launcher.png

Clic Modify Wwise…. And add it.

The SDK is required. It should also be added.

File:2024-02-09 16 35 29-Paramètres.png

Clic on Next to perform installation.

When ok, come back to Unity integration.

If SDK is not set, choose it :

File:2024-02-09 16 30 58-Audiokinetic Launcher.png

Wwise project need to be created. For that, leave the field empty :

File:2024-02-09 16 32 18-Audiokinetic Launcher.png

Unity integration is ready :

File:2024-02-09 16 38 02-Paramètres.png

Then, clic on Integrate.

File:2024-02-09 16 48 45-Audiokinetic Launcher.png

Now that the Wwise project is created in 2021 format, I can update the Wwise libraries in the Unity project.

File:2024-02-09 17 21 46-Audiokinetic Launcher.png

It's OK. In the screenshot I can update to the latest version 2023. I won't do that because I'm sure everything is fine with the versions I chose.

I will do a test later for the latest updates.

File:2024-02-09 18 29 10-Audiokinetic Launcher.png

Normaly, now, your Wwise project will appear on the Wwise Launcher. I work on my projects with the 2021 version of Wwise. I will open the Wwise project that was created:

File:2024-02-09 18 31 21-Audiokinetic Launcher.png

Step 2 : Wwise project[edit | edit source]

You need to create your sound databank :

File:2024-02-09 18 32 27-Kesa solar - Wwise 2021.1.13.png
File:2024-02-09 18 33 01-Kesa solar - Wwise 2021.1.13.png

Your soundbank is now created.

File:2024-02-09 18 34 25-Kesa solar - Wwise 2021.1.13.png

I'm only using windows plateform and English language but you can add/remove/modify :

File:2024-02-10 08 38 58-.png
File:2024-02-10 08 38 19-.png

Next step : importing your audio files. I'm using .wav format.

File:2024-02-09 18 35 12-.png
File:2024-02-09 18 36 43-Kesa solar - Wwise 2021.1.13.png

Select your wave file on your computer.

Then, import :

File:2024-02-09 18 37 25-Audio File Importer.png

My new sound appears on the list :

File:2024-02-09 18 38 28-Kesa solar - Wwise 2021.1.13.png

You can double click on you audio (for example if you want to set a loop) :

File:2024-02-09 18 40 54-Property Editor.png

And close the window.

Now, you have to set events with your audio for using in Unity : one for playing it, one for stopping it :

File:2024-02-09 18 44 46-.png
File:2024-02-10 05 45 52-Kesa solar - Wwise 2021.1.13.png

Clic on your new event for setting it :

File:2024-02-10 05 47 01-Kesa solar - Wwise 2021.1.13.png

Right clic on Target field for assign an audio to this event :

File:2024-02-10 05 47 57-Kesa solar - Wwise 2021.1.13.png

Select your audio :

File:2024-02-10 05 48 24-Kesa solar - Wwise 2021.1.13.png

Same event creation for stopping audio action :

File:2024-02-10 05 49 57-Kesa solar - Wwise 2021.1.13.png

Same for playing, assign your audio to this envent.

Now both events appear on the list :

File:2024-02-10 05 51 23-Kesa solar - Wwise 2021.1.13.png

To finish, you must assign new events to your soundbank. For that, select your soundbank and drag and drop your events on the bottom window :

File:2024-02-10 05 52 56-Kesa solar - Wwise 2021.1.13.png

Ok, ready now.

Now, just generate your soundbank for using it with Unity and your final mod :

File:2024-02-10 05 54 02-Kesa solar - Wwise 2021.1.13.png
File:2024-02-10 05 55 16-Generating SoundBanks - Completed.png

Your soundbank is now in your wwsise folder <Wwise Project>/GeneratedSoundBanks/Windows

You have to copy the file .bnk in your KSP2 mod folder <Your Mod>/assets/soundbanks/

Now, keep your Wwise Project open and start Unity.

Step 3 : Unity project[edit | edit source]

Normaly, both are connected. We will verify in the wwise picker window :

File:2024-02-10 06 18 27-kesasolar.Unity - Default - Windows, Mac, Linux - Unity 2022.3.5f1 DX11 .png

All your soundbank events normaly appear on this window.

I will show you 2 ways for using them.

Example 1 : add an engine sound[edit | edit source]

First, I create an empty gameobject for sound : u_amb_Engine

File:2024-02-10 06 24 23-kesa.Unity - Default - Windows, Mac, Linux - Unity 2022.3.5f1 DX11 .png

And on it few Components :

File:2024-02-10 06 25 59-Kesa solar - Wwise 2021.1.13.png

In Rigidbody, check "Is Kinematic" and uncheck "Use Gravity" !

Next, add audio Components :

File:2024-02-10 06 27 52-kesa.Unity - Default - Windows, Mac, Linux - Unity 2022.3.5f1 DX11 .png
File:2024-02-10 06 28 21-kesa.Unity - Default - Windows, Mac, Linux - Unity 2022.3.5f1 DX11 .png

For Rtpc mapping, I’ve created AllRTPC:

File:2024-02-10 06 34 51-kesa.Unity - Default - Windows, Mac, Linux - Unity 2022.3.5f1 DX11 .png

And for your engine audio :

File:2024-02-10 06 28 59-kesa.Unity - Default - Windows, Mac, Linux - Unity 2022.3.5f1 DX11 .png

I’ve select 2 events for playing and stopping my engine sound : engine3_play & engine3_stop

That’s all. Now your engine will have sound !!!

Example 2 : sound in animation[edit | edit source]

For this example, I will show a solar panel with animations for deploying and retracting.

First, I create an empty gameobject u_amb_audio_solar_arrays

File:2024-02-10 09 13 08-kesasolar.Unity - Default - Windows, Mac, Linux - Unity 2022.3.5f1 DX11 .png

I've add components on it :

File:2024-02-10 07 05 11-Kesa solar - Wwise 2021.1.13.png

In Rigidbody, check "Is Kinematic" and uncheck "Use Gravity" !

On the gameobject with Animator component :

File:2024-02-10 07 10 51-Kesa solar - Wwise 2021.1.13.png

Drag & drop your u_amb_audio_solar_arrays gameobject in Animation Events Object field.

Then, we can set audio in animations, on deploying and retracting.

On the first timeline, in your animation windows, on the first frame, right clic :

File:2024-02-10 07 14 49-Animation.png

And set in Inspector :

File:2024-02-10 07 15 36-Kesa solar - Wwise 2021.1.13.png

Same action for the last animation frame :

File:2024-02-10 07 16 29-Kesa solar - Wwise 2021.1.13.png

Now, my animation has 2 audio events (white rectangles), in the first frame to start the sound, in the last frame to stop it :

File:2024-02-10 07 17 23-Animation.png

Animations can have multiples sound events :

File:2024-02-10 07 18 54-Animation.png

That’s all, now your part has sounds.

You know as much as I do now. I hope this tutorial will help you.

Don't hesitate to provide feedback, corrections, ... I don't have the knowledge :-)