WEBVTT

00:00.000 --> 00:00.450
Hello guys.

00:00.450 --> 00:01.380
Welcome to the video.

00:01.380 --> 00:05.010
In this one we're going to set up audio effects for the game.

00:05.010 --> 00:07.110
Going to be pretty easy to do actually.

00:07.110 --> 00:11.190
And I guess we should start by doing something in the script folder.

00:11.190 --> 00:14.340
I didn't do it in the last video for some reason.

00:14.340 --> 00:16.500
Again, but let's just do it now.

00:16.500 --> 00:19.770
Let's do folder and let's call it managers.

00:20.610 --> 00:26.580
And I'm going to take camera manager, game manager and skin manager and drag them here to managers.

00:26.730 --> 00:31.410
And also I think I can make folder for cameras.

00:33.240 --> 00:34.110
Yeah, let me do it.

00:35.840 --> 00:40.820
Let me do folder camera and I'm going to take these two and drag them here.

00:41.090 --> 00:42.320
Uh something else.

00:42.320 --> 00:44.090
Oh there is difficulty manager.

00:46.300 --> 00:47.590
So you can take it.

00:47.590 --> 00:49.060
Bring it to managers.

00:49.390 --> 00:50.110
Nice.

00:50.110 --> 00:51.190
Now.

00:51.190 --> 00:51.640
No, no.

00:51.640 --> 00:54.520
Now let's make audio manager again.

00:54.520 --> 01:00.880
I'm going to do it in managers I'm going to make C sharp script audio manager.

01:02.820 --> 01:03.810
This is good.

01:03.840 --> 01:09.780
Now we need to go ahead and make a game object that would serve us as audio manager.

01:09.780 --> 01:10.950
Oh, there is a script.

01:10.950 --> 01:12.540
Let me drag it to scripts.

01:15.160 --> 01:16.240
And let it be there.

01:16.240 --> 01:16.900
It's okay.

01:17.980 --> 01:22.360
So we're going to create empty Audio manager.

01:23.140 --> 01:23.830
Very nice.

01:23.950 --> 01:26.560
And we need to add component of audio manager.

01:29.070 --> 01:30.750
And we're going to open the script.

01:31.080 --> 01:36.780
I think we're not going to destroy the audio manager on load, because there may be the case where you

01:36.780 --> 01:39.840
want to play the music and you don't want the music.

01:39.840 --> 01:41.730
Stop between level transitions.

01:41.730 --> 01:46.920
Otherwise, every time you restart the level, for example, when you die, you're going to start song

01:46.920 --> 01:50.130
from the beginning, and that can be very noticeable.

01:50.130 --> 01:57.660
So let's go ahead and do, uh, public static audio manager instance.

01:58.630 --> 02:00.070
Then we're going to do a wake.

02:00.220 --> 02:04.150
Don't destroy unload this game object.

02:04.150 --> 02:13.600
And then if instance is equals to null then instance this else we're going to destroy this game object.

02:13.930 --> 02:14.710
Nice.

02:15.670 --> 02:18.130
Uh, now let's take the header.

02:18.130 --> 02:20.950
Let's make header audio source.

02:20.950 --> 02:21.820
I'm going to call it that.

02:21.820 --> 02:28.150
And we're going to need serialized field private audio source array for sound effects.

02:28.150 --> 02:30.250
And I'm just going to call it SFX.

02:30.400 --> 02:31.120
All right.

02:31.120 --> 02:33.310
So we're going to take audios.

02:33.310 --> 02:37.270
And we're going to assign them into the field of audio source with the name SFX.

02:37.270 --> 02:43.120
And every time we need to play the audio, we're just going to call audio source with a certain index.

02:44.200 --> 02:46.600
It's going to make it much easier for us.

02:46.600 --> 02:48.700
Now let's go ahead and make.

02:49.030 --> 02:50.350
Public void.

02:50.350 --> 02:51.910
Play a suffix.

02:51.910 --> 02:55.390
And here we need to pass int a suffix to play.

02:55.390 --> 02:56.260
Very nice.

02:56.260 --> 03:02.380
Now first of all we want to check if the number we're trying to get is within range of the array we

03:02.380 --> 03:02.680
have.

03:02.680 --> 03:03.370
So I'm going to do.

03:03.400 --> 03:09.220
If suffix to play is bigger or equals to a suffix dot length, then I'm going to return.

03:09.220 --> 03:15.250
And if no I'm going to do suffix with a suffix to play dot play.

03:16.260 --> 03:19.530
Also, there may be the case when you need to stop a suffix.

03:19.620 --> 03:23.400
I don't think it's going to happen in this game, but maybe you have some long sound effects that you

03:23.400 --> 03:24.420
will find later on.

03:24.420 --> 03:32.220
So for that purpose you could use public void stop suffix and you would just pass int a suffix to stop.

03:32.220 --> 03:36.030
That would do a suffix suffix to stop.

03:36.030 --> 03:41.310
And I'm not checking index of Linux here, because if you could play this sound effect, obviously you

03:41.310 --> 03:43.080
could stop the sound effect, right?

03:43.080 --> 03:43.950
Yes.

03:43.950 --> 03:44.880
Okay.

03:44.880 --> 03:47.130
Believe me or not, this is enough.

03:47.310 --> 03:54.510
Now let's go back to unity and we're going to go to asset and make a folder for audio.

03:54.990 --> 03:59.430
And you're going to open the archive that is attached to this video.

03:59.430 --> 04:03.180
Because there I've collected some sounds for the game.

04:03.180 --> 04:09.420
It is not the best sounds you could find, but I think they'll work pretty much okay for the game we

04:09.420 --> 04:10.140
have here.

04:10.140 --> 04:14.340
In the end of the day, we just make a study project, right?

04:14.340 --> 04:18.390
So it's not supposed to be perfect and we just need the system itself.

04:19.050 --> 04:22.290
So there are the sounds and we're going to use them as example.

04:22.290 --> 04:26.400
And in the end of this section I'm going to show you where to find more sounds.

04:26.400 --> 04:29.820
If you like I'm going to show you places, different websites.

04:29.820 --> 04:33.630
And also I'm going to explain a couple of things about sound effects.

04:33.630 --> 04:35.550
So let's just use these for now.

04:36.890 --> 04:41.540
Um, I have this menu select sound and let me check if I'm recording them.

04:41.540 --> 04:42.740
This is important.

04:51.660 --> 04:54.510
Okay, I think I do record sounds.

04:54.510 --> 04:55.320
Let me try.

04:56.810 --> 04:58.490
Yeah I do okay.

04:58.490 --> 05:02.360
So these could be used for menu selection for example.

05:02.360 --> 05:02.780
Right.

05:02.780 --> 05:06.110
And other things for the things they are like named for.

05:06.110 --> 05:06.380
Right.

05:06.380 --> 05:07.820
There's death finish jump.

05:07.820 --> 05:11.330
So on first of all we need to take all of the sounds here.

05:12.180 --> 05:14.850
We need to drag them into the scene like that.

05:15.060 --> 05:18.330
Then for all of them, we need to uncheck play on awake.

05:18.330 --> 05:21.990
If you don't do that, all of the sounds will be played when you start the game.

05:23.730 --> 05:29.070
If you cannot hear the sounds, you need to click this icon over here because your game might be muted.

05:29.100 --> 05:30.510
Let me try again.

05:33.970 --> 05:34.840
Oh, wow.

05:34.870 --> 05:36.130
Yeah, that was crazy.

05:36.130 --> 05:39.430
So we have to disable play on awake over here.

05:39.430 --> 05:42.430
Then you would have to adjust volume for different sounds.

05:42.430 --> 05:45.160
That is more about, you know, setup of the sound.

05:45.160 --> 05:51.100
Like you need to do detailed setup for the sound effects, because sound is very important for the game.

05:51.100 --> 05:53.740
But that's not the most important thing right now.

05:53.740 --> 05:56.740
For now, we just need to make a parent for these sound effects.

05:56.770 --> 06:01.240
I'm going to make parent sound effects.

06:02.280 --> 06:04.650
And then I'm going to make parent for this one.

06:05.100 --> 06:06.960
I actually we don't need to I'm sorry.

06:06.960 --> 06:08.070
We have audio manager.

06:08.070 --> 06:11.250
So let's drag it and make it as child of audio manager.

06:11.490 --> 06:12.510
Nice.

06:12.510 --> 06:14.730
Now for the sound effects.

06:14.730 --> 06:17.340
We could manually drag them here.

06:17.340 --> 06:21.210
Or we could write a script that would collect all of the sounds.

06:21.210 --> 06:24.000
And I think I'm just going to drag them.

06:24.000 --> 06:24.420
Why not?

06:24.420 --> 06:30.690
Let's just click the lock it over here and let's take the sound and drag them to the array like so.

06:31.700 --> 06:32.360
Perfect.

06:32.360 --> 06:38.780
Now you can see each sound here has a number, and if you want to play a certain sound, you just need

06:38.780 --> 06:41.480
to pass the index number over here.

06:41.480 --> 06:48.140
I mean from here example we can go to canvas and find a place where we click buttons.

06:49.840 --> 06:53.140
For example, we click a button every time we switch UI.

06:53.140 --> 06:58.840
So I'm going to do Audio Manager dot instance play SFX and we need to know the number.

06:58.840 --> 07:02.110
So I'm going to pick into unity and see that.

07:02.850 --> 07:05.790
There is this menu select with number four.

07:05.790 --> 07:07.680
So I'm going to play it number four.

07:08.720 --> 07:11.450
We also need to play the sound when we start new game.

07:11.450 --> 07:19.340
So I'm going to duplicate it, place it here, and maybe we can duplicate it again and call it when

07:19.340 --> 07:22.280
we continue the game over here.

07:22.280 --> 07:23.300
Just like that.

07:23.920 --> 07:26.470
In essence, I think.

07:28.040 --> 07:29.090
This should be okay.

07:29.120 --> 07:32.060
So now we have three places we call the sound.

07:33.190 --> 07:33.670
Right.

07:33.670 --> 07:37.000
Switch UI new game and continue game.

07:37.860 --> 07:39.030
I'm going to save this.

07:39.060 --> 07:42.420
Go back to menu and go to play mode.

07:45.420 --> 07:46.560
And I'm clicking.

07:46.560 --> 07:47.340
New game.

07:47.880 --> 07:49.050
There is a sound.

07:52.300 --> 07:54.130
These two supposed to play sound as well?

07:54.130 --> 07:55.930
I kind of forgot we're going to fix it.

07:56.560 --> 07:57.460
And.

07:58.440 --> 07:59.730
There was no sound.

07:59.730 --> 08:04.350
So, um, skin selection button have to play sound.

08:04.530 --> 08:06.570
Let's go to skin selection.

08:10.380 --> 08:11.010
Uh.

08:11.010 --> 08:12.180
Over here.

08:13.530 --> 08:21.270
I'm going to play a sound here and on the next screen and on the previous screen like that, I could

08:21.270 --> 08:26.250
call it in the update screen display once, but this method is called at the start as well.

08:26.250 --> 08:28.380
And I guess we don't need to play sound then.

08:28.380 --> 08:33.210
So I'm just going to call it three times here, here and here.

08:33.210 --> 08:33.930
Perfect.

08:33.930 --> 08:35.190
Let's save this.

08:36.380 --> 08:39.860
And let's go and try that again.

08:42.640 --> 08:42.910
Oh, no.

08:42.910 --> 08:43.270
Wait.

08:43.270 --> 08:44.680
Elsew level button.

08:45.250 --> 08:46.540
The level button.

08:46.540 --> 08:48.850
Level button is over here.

08:48.850 --> 08:50.260
Let's go to level button.

08:51.930 --> 08:54.840
And every time we load the level.

08:56.100 --> 08:57.240
You're going to play sound.

08:57.720 --> 08:58.440
Okay.

08:58.560 --> 08:59.520
That's good.

08:59.550 --> 09:00.870
Now this will work.

09:00.870 --> 09:05.040
Also want to go and make the sound lower in volume because I feel it's too loud.

09:05.040 --> 09:09.720
So I'm going to do point four and let's just check it.

09:17.470 --> 09:18.580
Looks okay to me.

09:20.450 --> 09:20.930
All right.

09:20.930 --> 09:22.040
We are in the game.

09:22.040 --> 09:22.550
Perfect.

09:22.550 --> 09:24.020
Now let's go to the next video.

09:24.020 --> 09:26.630
I'm going to show you how to set up in game sounds.

09:26.630 --> 09:31.040
And also I'm going to show you how to improve sounds so they can sound a little bit different every

09:31.040 --> 09:31.880
time you use them.
