WEBVTT

00:00.080 --> 00:01.960
Let's add audio to our game.

00:01.960 --> 00:08.120
But before you add audio to your game, make sure you select your main camera in the hierarchy and audio

00:08.120 --> 00:11.320
listener is a component is attached to your main camera.

00:11.320 --> 00:16.600
If it's not, then click on this add component and find the component by typing name of the component,

00:16.600 --> 00:19.640
which is in our case Audio listener.

00:20.160 --> 00:21.000
So attach that.

00:21.000 --> 00:22.560
So I'm not gonna do it again.

00:22.560 --> 00:28.160
I already have attached audio listener component as you can see inside this main camera.

00:28.160 --> 00:30.360
So why this component is important.

00:30.360 --> 00:33.800
Basically this component just gonna work as a microphone.

00:33.800 --> 00:37.920
It's going to take sound from source and then it's gonna play our sound.

00:37.920 --> 00:44.240
So that's why we need to uh make sure audio listener component is it's attached to this main camera

00:44.600 --> 00:45.320
or not.

00:45.440 --> 00:51.840
So that's why this audio listener component is by default attached to attached to this main camera.

00:51.880 --> 00:52.600
Always.

00:52.960 --> 00:55.760
So so let's uh, add audio to our game.

00:56.040 --> 00:59.200
So firstly I'm going to create an empty game object for that.

00:59.200 --> 01:01.000
So let's move over to this hierarchy.

01:01.050 --> 01:03.010
right click or hit this plus icon.

01:03.010 --> 01:05.290
And we're going to create an empty game object.

01:05.290 --> 01:10.450
And we will call this game object something like audio or audio or audio Manager.

01:10.450 --> 01:11.850
So I'm going to call it audio.

01:12.010 --> 01:13.290
Let's go to transform.

01:13.290 --> 01:14.370
Let's reset it.

01:14.370 --> 01:17.330
And I'm going to select my audio GameObject in the hierarchy.

01:17.330 --> 01:20.770
And I'm going to drag it in the top so I can see all the time.

01:20.970 --> 01:27.490
And in order to play an audio clip we need to add a source called audio was sorry.

01:27.530 --> 01:30.530
We need to attach a component called audio source.

01:30.530 --> 01:34.890
So basically what you have to do, you need to select the game object first in the hierarchy.

01:34.930 --> 01:36.810
Then click on this add component.

01:36.810 --> 01:39.610
And we're going to add a component called audio source.

01:39.610 --> 01:40.930
So we're going to type the component.

01:40.970 --> 01:43.970
We're going to find the component by typing name of the component.

01:43.970 --> 01:45.730
So in our case audio source.

01:46.130 --> 01:51.130
And what we have to do now in this audio source component we need to drag the clip.

01:51.130 --> 01:56.650
Which clip we just want to play in in inside this audio resource slot.

01:56.650 --> 01:58.890
So we need to drag the clip over here.

01:59.130 --> 02:00.930
So I have in my project app.

02:00.930 --> 02:05.010
So I will move over to my project tab assets and then audio folder.

02:05.450 --> 02:08.330
I have all of this audio as you can see.

02:08.370 --> 02:12.290
Of course I will have a link in the resources of all of this.

02:12.290 --> 02:14.530
So you can go and check that out.

02:14.530 --> 02:17.970
So let's suppose I want to play this drum sound.

02:18.290 --> 02:20.530
I hope you are able to hear it.

02:20.850 --> 02:23.010
So I just want to play the drum sound.

02:23.010 --> 02:26.170
So I'm going to select my audio GameObject in the hierarchy.

02:26.170 --> 02:29.450
And let's select the jump clip from that folder.

02:29.450 --> 02:32.770
And let's drag it over to this audio resource slot.

02:32.810 --> 02:36.810
Basically the clip you want to play, you need to drag it over here.

02:37.170 --> 02:43.010
And if we just click on this play button in the top by now, you will be able to hear that sound right

02:43.010 --> 02:44.370
after the game start.

02:44.410 --> 02:44.850
Why?

02:44.890 --> 02:48.090
Because this play on awake is checked, so that's why.

02:48.890 --> 02:51.770
So just wait a little moment to start our game.

02:54.970 --> 02:59.770
So as you hear, as soon as the game started, that jump sound just gets played.

02:59.770 --> 03:01.330
So I'm gonna get out of play mode.

03:01.340 --> 03:04.220
So that's why we need to uncheck this play on awake.

03:04.220 --> 03:05.540
So the sound.

03:05.580 --> 03:08.220
Not gonna play right after the game start.

03:08.220 --> 03:13.380
And if you want your sound to be low then you can just check this loop over here.

03:13.380 --> 03:16.020
It's gonna play the sound in looping.

03:16.340 --> 03:22.980
And you can just play around with these properties like volume pitch, studio pen and as well spatial

03:23.020 --> 03:23.500
blend.

03:23.500 --> 03:29.740
So if you just drag this spatial plane to 3D, the sound just gonna work as 3D.

03:29.740 --> 03:36.300
So if the sound source is far from our main camera or this audio listener component which is attached

03:36.300 --> 03:40.100
to our main camera, we do know and it's work as a microphone.

03:40.100 --> 03:46.820
So if you drag any audio source far from your audio listener component, the sound just gonna the volume

03:46.820 --> 03:54.020
of that sound will be down because it's too much, uh, too much far away from this audio listener component

03:54.060 --> 03:55.660
on from this main camera.

03:55.820 --> 03:59.500
A in this camera we do no audio listener component is added.

03:59.500 --> 04:03.030
We which work like as a microphone.

04:03.030 --> 04:04.150
So that is the thing.

04:04.150 --> 04:05.710
I hope you get the idea.

04:05.710 --> 04:11.550
But we don't want to play this audio uh, so or sorry this dumb claim whenever the game starts.

04:11.550 --> 04:13.950
So that's why we just uncheck the loop time.

04:13.950 --> 04:16.070
And we want to play this jump sound.

04:16.110 --> 04:19.990
Once we just play, uh, play the jump animation clip.

04:19.990 --> 04:22.110
Once our player game object jumps.

04:22.150 --> 04:25.790
At that moment we're gonna play this jump sound or this jump clip.

04:25.790 --> 04:29.750
So we're going to create a script for that in order to make our jump sound.

04:29.750 --> 04:33.310
When we're jumping for that, let's create a script.

04:33.310 --> 04:38.710
So we will move over to our project tab, then assets, and then in script folder let's right click

04:38.710 --> 04:41.390
there, then create Monobehaviour script.

04:41.390 --> 04:43.990
And you can name that script whatever you like.

04:44.030 --> 04:47.510
I already have created a script called Sound Manager.

04:47.510 --> 04:48.630
As you can see.

04:48.630 --> 04:52.510
You can name it to something like Audio Manager is as well.

04:52.510 --> 04:53.790
It's totally up to you.

04:53.790 --> 04:58.590
So I'm going to select my audio GameObject in the hierarchy, and let's select that Sound Manager script

04:58.590 --> 05:01.270
and drag it over to this Add Component section.

05:01.270 --> 05:04.840
And we're going to double click on this to open it up in Visual Studio.

05:05.000 --> 05:09.760
And what I'm gonna do I'm going to remove this start and update function I don't need.

05:09.800 --> 05:12.920
Instead we need a reference of this audio source.

05:12.920 --> 05:17.600
So if we move over to unity we need a reference of this audio source component.

05:17.600 --> 05:19.520
Then we can play this jump clip.

05:19.520 --> 05:22.200
So we need a reference of this audio source.

05:22.200 --> 05:23.880
So let's grab the reference first.

05:23.880 --> 05:28.240
So let's move to our scale and let's create a field for that.

05:28.240 --> 05:30.320
So we're going to make a serialized field.

05:30.600 --> 05:32.920
Or you can just leave it public as well.

05:33.440 --> 05:35.360
It's not complicated at all.

05:35.360 --> 05:36.720
So I'm going to make public.

05:36.720 --> 05:39.680
And the component we're looking for is the audio source.

05:39.680 --> 05:42.480
So we're going to type audio source audio source.

05:42.480 --> 05:45.160
And we have to name the source what we want to name it.

05:45.160 --> 05:52.480
So I'm going to call something like jump audio source jump audio source source.

05:52.480 --> 05:54.360
And let's close that out semicolon.

05:54.360 --> 05:57.000
And let's press down Ctrl S to save our skip.

05:57.000 --> 05:58.400
And let's move to unity.

05:58.400 --> 06:04.840
So underneath our sound manager Skip we will see an empty field of jam audio source just gonna pop up.

06:04.840 --> 06:10.600
So what we have to do there, we need to drag this audio source, uh, reference into that slot.

06:10.600 --> 06:15.640
So we're gonna have the reference, and then we can just play the sound that we really want to play

06:15.640 --> 06:18.960
once we're making jumping our player game object.

06:18.960 --> 06:24.800
So as you can see, as soon as our sound manager script gets compiled, we can see a field just pop

06:24.840 --> 06:29.960
up underneath our sound manager script jump audio source and it says none audio source.

06:29.960 --> 06:35.640
So what we have to do over here, we need to take this audio source and let's drag it into that field.

06:35.680 --> 06:39.800
And now we can see we have the audio source reference basically this one.

06:39.800 --> 06:41.640
And now we are ready to play.

06:41.760 --> 06:43.920
So let's open up our script quickly.

06:44.200 --> 06:50.360
And for that we're gonna do we're gonna make a function in order to play the jump uh, audio clip.

06:50.360 --> 06:52.400
So we're gonna make this function public.

06:52.400 --> 06:52.680
Why?

06:52.720 --> 06:57.560
Because we're gonna call this function from another class or another C sharp script.

06:57.560 --> 07:00.440
So that's why we need to make this function as a public.

07:00.640 --> 07:04.530
And for function we're going to type void and we have to name the function.

07:04.530 --> 07:10.090
So I'm going to call it something like play jump jump audio sound or something like that.

07:10.090 --> 07:14.370
So play jump sound as jump sound.

07:14.410 --> 07:17.450
And let's make first bracket and some curly brackets.

07:17.450 --> 07:21.770
And what we want to do inside this function, we just want to play the jump clip.

07:21.770 --> 07:25.370
So basically what we need to do, we need to move over to this audio source.

07:25.370 --> 07:29.530
And we're going to use play function in order to play this jump audio clip.

07:29.530 --> 07:30.850
So we need to use that.

07:30.850 --> 07:34.210
So let's move over to first or that audio source component.

07:34.210 --> 07:38.290
So in our case audio source and we do know we have the reference.

07:38.290 --> 07:40.410
So let's move over to jump audio source.

07:40.410 --> 07:44.370
Basically we just simply moving over to that audio source component.

07:44.370 --> 07:49.810
And we're gonna use this dot play function in order to play the clip and then make first bracket and

07:49.810 --> 07:51.530
close that up with semicolon.

07:51.530 --> 07:54.290
And we're going to press down Ctrl S to save our skip.

07:54.290 --> 07:55.650
And let's move to unity.

07:55.650 --> 08:03.340
So if we call that play jump audio source function or that play jump sound, it's gonna what it's gonna

08:03.340 --> 08:03.420
do.

08:03.460 --> 08:08.620
It's gonna move over to that audio source, which in our case, dumb audio source or that audio source

08:08.620 --> 08:09.260
component.

08:09.260 --> 08:13.540
And we're using this play function in order to play our jump clip.

08:13.540 --> 08:15.460
So we also need to call the function.

08:15.460 --> 08:22.540
But when we shoot once this player game object just making our jump when it's jumping, we're gonna

08:22.540 --> 08:23.620
play that function.

08:23.820 --> 08:24.180
Uh, sorry.

08:24.180 --> 08:31.100
We're gonna call that play jump sound function and that function just moving over to this audio source

08:31.100 --> 08:35.980
and then using play function in order to play this jump clip as you seen.

08:35.980 --> 08:37.380
So let's call the function.

08:37.380 --> 08:40.220
So we're gonna call the function inside our player skip.

08:40.220 --> 08:42.740
So let's select the player game object in the hierarchy.

08:42.740 --> 08:44.500
And let's open up the player skip.

08:44.500 --> 08:47.740
And let's move over to that line of code where we're jumping.

08:47.740 --> 08:51.260
So we can see we're jumping over here as you can see.

08:51.420 --> 08:56.980
So we're just making our jump, then setting his ground then making our jump animation clip.

08:56.980 --> 09:02.350
So also we just want to play the jump audio source uh or that jump Jam sound.

09:02.350 --> 09:04.350
So what we will do, we will use this.

09:04.350 --> 09:07.950
Find any object, uh, by type and then make these arrows.

09:07.950 --> 09:14.230
So if you have used singleton then you can simply move over to that script and you can just pass the

09:14.230 --> 09:17.030
name of the script instead of doing like this.

09:17.030 --> 09:24.150
So you can use the singleton pattern, which I have explained in my, uh, clean code, uh, lecture.

09:24.150 --> 09:27.630
So you can check that out in order to use singleton pattern.

09:27.870 --> 09:32.630
So this we need to use this find any object by type and into this arrows.

09:32.630 --> 09:35.870
We need to pass the script name that we are looking for.

09:35.870 --> 09:39.310
So simply we're gonna move over to that sound manager script.

09:39.390 --> 09:46.230
And we do know inside that script we have created that some, uh, some sound, uh, play play, jump

09:46.270 --> 09:47.350
sound, uh function.

09:47.350 --> 09:48.310
So we're going to call that.

09:48.310 --> 09:52.670
So let's head over to our sound manager script first, then make first bracket.

09:52.670 --> 09:56.550
And from there we're going to call the play jump sound function.

09:56.550 --> 09:57.350
So let's call it.

09:57.350 --> 10:00.190
So we're going to use this dot play jump sum function.

10:00.190 --> 10:03.950
And uh make first bracket and then close that up with semicolon.

10:03.950 --> 10:08.390
And we're going to press down Ctrl S to save our scope and save our script.

10:08.390 --> 10:13.550
So once we're making our jump then what we're doing we're just moving over to our sound manager script.

10:13.550 --> 10:19.830
Basically we're just going over to this Sound Manager C class and then calling this jump play jump sound

10:19.950 --> 10:20.430
function.

10:20.430 --> 10:25.390
And what this function is doing is just going over to that audio source component, which is in our

10:25.390 --> 10:28.710
case, jump audio clip, uh, audio source.

10:28.710 --> 10:33.510
And then using this dot play function in order to play the sound.

10:33.510 --> 10:35.310
And let's move to unity by now.

10:35.470 --> 10:39.270
Uh, firstly make sure you just press down Ctrl s to save your script.

10:39.270 --> 10:41.670
And after that just move over to unity.

10:41.670 --> 10:44.510
So I'm going to press Ctrl S to save my script.

10:44.510 --> 10:45.830
And let's move to unity.

10:46.310 --> 10:47.750
And it should be fine.

10:48.030 --> 10:51.390
So I'm going to select my audio GameObject in the hierarchy.

10:51.390 --> 10:53.830
And let's click on this play button in the top.

10:53.830 --> 10:58.550
And you will see as soon as we're gonna make jump our player, jump the jump sound.

10:58.550 --> 11:00.710
Just gonna play right away.

11:03.520 --> 11:11.120
So if I jump, as you can see, as soon as we jump in, we just are making our player jump sound.

11:11.120 --> 11:12.760
So this is, uh, cool.

11:13.000 --> 11:17.480
I hope you get the idea that how you can do it and let's, uh, play as well.

11:17.520 --> 11:19.120
Explosion sound.

11:19.480 --> 11:20.440
Explosion sound.

11:20.440 --> 11:27.320
Basically, once this player game object dies, it should play the explosion sound once it's died.

11:27.320 --> 11:30.760
So let's get out of play mode and let's do that thing as well.

11:31.120 --> 11:36.840
Uh, so for that, we're going to add a another audio source component, uh, for that explosion sound.

11:36.840 --> 11:39.880
Once this player game object dies, we're gonna play that sound.

11:39.880 --> 11:44.160
So that's why we're gonna add a another audio source component for it.

11:44.160 --> 11:46.880
So let's select the audio GameObject in the hierarchy.

11:46.880 --> 11:48.800
And let's click on this add component.

11:48.800 --> 11:51.160
And we're gonna add a another audio source.

11:51.160 --> 11:56.800
And we need to drag the clip over here that we want to play inside this audio resource slot.

11:56.800 --> 12:00.520
So let's move to project app Assets and an audio folder.

12:00.520 --> 12:06.730
And I'm going to select my this explosion audio clip, and I'm gonna drag it over to inside this audio

12:06.730 --> 12:08.490
resource slot slot.

12:08.490 --> 12:10.730
And I'm gonna uncheck this play on awake.

12:11.050 --> 12:16.170
Basically, I don't want to play this explosion sound clip as soon as the game started.

12:16.570 --> 12:22.770
So that's why I just uncheck and let's, uh, make a another function in order to play this explosion

12:22.770 --> 12:24.290
sound clip as well.

12:24.290 --> 12:25.970
So let's open up our player script.

12:25.970 --> 12:30.570
But before we do I'm gonna move this audio source component up direction.

12:30.570 --> 12:33.650
So I'm going to right click on it and let's click on this move up.

12:33.650 --> 12:37.570
In order to move this component in top of this Sound Manager script.

12:37.570 --> 12:40.450
And let's open up our script first.

12:40.690 --> 12:46.250
So we also need a reference of this audio source of this explosion sound clip as well.

12:46.290 --> 12:48.330
Explosion sound clip audio source.

12:48.330 --> 12:49.650
We need reference.

12:49.650 --> 12:55.050
So let's go to script and let's make another uh, another parameter for that.

12:55.050 --> 13:00.730
So let's make this one public so we can see or we can adjust underneath our sound manager script.

13:00.770 --> 13:06.460
And that is audio source that the component we're looking for and we have to name the component.

13:06.460 --> 13:09.420
So I'm going to call this one something like explosion.

13:09.740 --> 13:12.300
Explosion audio source.

13:12.340 --> 13:14.460
Explosion audio source.

13:14.780 --> 13:16.780
And let's close that up with semicolon.

13:16.780 --> 13:19.740
And let's press down Ctrl S to save our script.

13:19.980 --> 13:25.060
And let's move to unity, uh, in order to drag the reference in that slot.

13:25.100 --> 13:30.860
And after that, we're going to make the function in order to play the explosion sound as well.

13:30.860 --> 13:32.420
So just wait for to compile.

13:32.420 --> 13:34.980
And once it's done, we are ready to do that.

13:34.980 --> 13:38.900
We need to drag in, uh, inside our sound manager script.

13:39.500 --> 13:43.780
So now we can see another explosion audio source component just appear.

13:43.780 --> 13:45.580
So we're going to take this audio source.

13:45.780 --> 13:52.900
But make sure you just drag the explosion audio source component into that slot instead of this jump.

13:52.900 --> 13:56.100
So we're going to take this audio source and let's drag it right there.

13:56.140 --> 14:02.020
Make sure you before you drag it's a correspond to a correspondingly match up.

14:02.020 --> 14:03.660
So make sure you just do that.

14:03.660 --> 14:06.060
And let's open up our script by now.

14:06.060 --> 14:11.820
And let's make another function in order to play that explosion sound effect as well.

14:11.820 --> 14:13.380
I'm gonna make it in the bottom.

14:13.380 --> 14:15.340
You can make it anywhere you want.

14:15.380 --> 14:17.620
It doesn't need to be or in order.

14:17.620 --> 14:19.020
So let's make another.

14:19.300 --> 14:24.140
So we're making this, uh, public, this function public because we're going to call this function

14:24.140 --> 14:28.220
as well from another C sharp class or another C sharp shape.

14:28.260 --> 14:30.980
And for function we will type, uh white.

14:31.020 --> 14:35.100
And we have to name the function what we would like to go with.

14:35.100 --> 14:43.180
So I'm going to call it something like uh play explosion explosion sound effect explosion sound something

14:43.180 --> 14:43.780
like that.

14:43.780 --> 14:46.500
Make first bracket and some curly brackets.

14:46.500 --> 14:50.100
And what we want to do inside this function, we basically move.

14:50.140 --> 14:52.780
We need to move over to this audio source component.

14:52.780 --> 14:58.940
And then we need to use the play function in order to play the play the explosion sound effect.

14:58.940 --> 15:00.060
So let's use that.

15:00.060 --> 15:05.550
So firstly we're going to move over to explosion audio source, and let's use this dot play function

15:05.550 --> 15:07.150
in order to play the sound.

15:07.150 --> 15:11.910
And let's make first bracket and then close that up with semicolon and we will press down space.

15:11.990 --> 15:14.110
Sorry Ctrl s to save our script.

15:14.270 --> 15:20.070
And we're going to call the function once our player game object dies as well as we're going to call

15:20.070 --> 15:23.230
the function once our enemy game object dies.

15:23.270 --> 15:23.670
Why.

15:23.790 --> 15:30.310
Because we do know once our enemy and this player just dies, we need to play the explosion sound and

15:30.310 --> 15:31.390
it's gonna make cool.

15:31.390 --> 15:32.390
So that is the thing.

15:32.390 --> 15:35.790
We're gonna call it multi, um, multiple times.

15:36.150 --> 15:38.470
So let's select our player game object first.

15:38.470 --> 15:41.390
So we're going to select our player game object in the hierarchy.

15:41.390 --> 15:43.110
And let's open up the player scape.

15:43.110 --> 15:47.190
And let's move over to die function where we destroying our player game object.

15:47.190 --> 15:50.350
And we can see we're destroying our player game object here.

15:50.550 --> 15:55.350
And I'm gonna make it in the bottom somewhere before we destroy our player game object.

15:55.350 --> 15:56.350
So let's use this.

15:56.350 --> 16:02.590
Find any object by type in order to call the function, or in order to head over to that script.

16:02.710 --> 16:03.640
So into arrows.

16:03.640 --> 16:05.120
We need to pass the script name.

16:05.120 --> 16:08.640
So in our case sound manager let's make first bracket.

16:08.640 --> 16:12.280
And inside that sound manager C sharp class or that script.

16:12.280 --> 16:16.240
We just created that play uh play explosion sound.

16:16.240 --> 16:17.680
So let's call it here.

16:17.840 --> 16:21.040
So we're gonna call Dot play explosion sound.

16:21.040 --> 16:25.160
And let's make first bracket and some enclose that up with semicolon.

16:25.160 --> 16:27.880
And let's press down Ctrl S to save our script.

16:28.000 --> 16:34.280
And I'm gonna copy this line of code by Ctrl C, and I'm gonna paste inside my anime one as well as

16:34.320 --> 16:36.840
anime two, where basically anime is dying.

16:36.880 --> 16:38.960
So let's head over to this anime script.

16:38.960 --> 16:41.760
And anime is dying here, as you can see.

16:41.760 --> 16:48.200
So we also want to play once our anime GameObject dies, we just want to play the explosion sound.

16:48.200 --> 16:50.840
So I'm gonna paste over here before we die.

16:50.880 --> 16:53.040
So I'm gonna paste it here as well.

16:53.040 --> 16:56.600
And let's press down Ctrl S to save our script one more time.

16:56.600 --> 17:01.440
And let's move to this anime two script where our anime two GameObject dying.

17:01.440 --> 17:03.730
So here we're just taking our camera.

17:03.730 --> 17:09.010
And after that I'm going to paste this line of code and let's press down Ctrl S to save our script and

17:09.010 --> 17:10.170
let's move to unity.

17:10.170 --> 17:16.330
So basically we're just calling the play explosion sound whenever our enemy as well as our player game

17:16.370 --> 17:17.210
object dying.

17:17.250 --> 17:18.890
We're just calling that function.

17:18.890 --> 17:25.130
And that function basically moving over to that audio source, which in our case our explosion audio

17:25.130 --> 17:31.090
source component, and then using that dot play function in order to play the clip that we want to play.

17:35.130 --> 17:41.050
So if I select my audio GameObject in the hierarchy, you can see we have to reference.

17:41.290 --> 17:42.570
And now it's fine.

17:42.890 --> 17:46.530
So let's click on this play button in order to play our game.

17:46.690 --> 17:49.050
And let's have a look on this.

17:57.450 --> 18:02.090
So just wait and we're gonna see it.

18:05.780 --> 18:06.900
So let's die.

18:06.940 --> 18:07.620
I'm gonna.

18:10.820 --> 18:12.300
So let's die.

18:14.340 --> 18:16.020
And we're not dying at all.

18:16.500 --> 18:18.300
So we still able to jump.

18:18.300 --> 18:24.380
So, as you can see, as soon as we died, that sound just clip that explosion sound.

18:24.380 --> 18:26.540
Just play a place right away.

18:26.540 --> 18:32.300
And I'm gonna click on this retry button in order to, uh, see it one more time.

18:32.300 --> 18:38.580
So let's take damage from this enemy or this enemy one as well, or we're going to destroy this enemy

18:38.580 --> 18:45.900
game object as well, in order to see or to hear that, uh, jump sound clip, which is we doing?

18:45.940 --> 18:50.980
As you can see, as soon as enemy one as well as this enemy two is dying.

18:51.140 --> 18:57.660
That sound just playing right away, which is the explosion sound that we want to play.

18:57.780 --> 19:04.860
And you can just ignore these errors in the console tab, and we can see as soon as our player GameObject

19:04.900 --> 19:06.420
dies as well.

19:06.420 --> 19:09.980
That explosion sound clip just plays right away.

19:10.220 --> 19:15.340
So basically that is the thing, and I'm gonna get out of play mode and let's make this one audio game

19:15.380 --> 19:17.180
object as well, a prefab.

19:17.180 --> 19:24.540
So we're gonna have the copy and we can use or reuse this audio game object in order to play in multiple

19:24.540 --> 19:26.060
levels as well.

19:26.060 --> 19:31.460
So let's select our audio GameObject in the hierarchy, and let's drag it over to this prefabs folder

19:31.460 --> 19:35.540
in our assets folder in order to turn it into a prefab.

19:35.940 --> 19:37.820
Uh, so I hope you get the idea.

19:37.820 --> 19:44.740
And let's suppose you just want to get it in more depth about audio manager and you don't want to use

19:45.420 --> 19:48.380
sorry, you don't want to use, uh, in this way.

19:48.780 --> 19:53.140
Then of course I will have a video, another video in the resources.

19:53.140 --> 20:00.740
You can go and check that out if you just want to learn about more about audio in depth deeply, then

20:00.740 --> 20:06.710
you can check that out and you can use that audio manager script or the sound manager script there,

20:06.710 --> 20:09.990
which is pretty much fine instead of using this way.

20:10.030 --> 20:14.310
So this basically is a beginner tutorial or this beginner course.

20:14.310 --> 20:17.590
So that's why I'm just explaining in depth way.

20:17.590 --> 20:18.950
I hope you get the idea.

20:18.950 --> 20:24.550
And now we need to play the theme that we want to play or the music we just want to play.

20:24.550 --> 20:27.670
So we're going to select our audio game object in the hierarchy.

20:27.670 --> 20:29.910
And let's click on this add component.

20:29.910 --> 20:35.310
And we will add a another audio source component in order to play uh the theme.

20:35.350 --> 20:37.830
And let's click over here in order to expand.

20:37.830 --> 20:41.030
And we need to drag the clip which clip we want to play.

20:41.030 --> 20:43.350
So I'm going to head over to my audio folder.

20:43.350 --> 20:46.230
Let's suppose I want to play this one.

20:46.230 --> 20:49.150
So this uh theme as you here heard.

20:49.190 --> 20:55.870
So I'm going to select that and drag it over to sorry I'm going to drag over to this audio resource

20:55.870 --> 20:57.070
loss slot.

20:57.110 --> 20:58.030
Uh slot.

20:58.070 --> 21:00.830
So let's select that clip and drag it here.

21:00.830 --> 21:02.990
And I'm going to leave this play on awake.

21:03.030 --> 21:03.430
Why.

21:03.560 --> 21:08.040
Because I want this theme or the music as soon as the game starts.

21:08.040 --> 21:11.480
And I want this theme or the music to be looped.

21:11.480 --> 21:16.640
So that's why I'm gonna also check this loop time or this loop box as well.

21:16.640 --> 21:22.640
And I'm gonna leave this play on awake because I want to play the music or the theme as soon as the

21:22.640 --> 21:23.480
game starts.

21:23.480 --> 21:25.080
So that's why I just leave this.

21:25.080 --> 21:30.160
And also we just check this loop in order to loop our music.

21:30.480 --> 21:36.280
And let's click on this play button by now, and you will hear the sound as soon as the game's gonna

21:36.320 --> 21:42.440
start, the theme or the music will be play right away as well, so have a look on it.

21:46.000 --> 21:50.280
As you can hear, as soon as the game started, I'm gonna get out of play mode.

21:50.520 --> 21:57.120
Uh, the that music or the theme just plays right away because we just, uh, check that play on awake

21:57.280 --> 22:04.080
as well as, uh, that, uh, basically loop time and I'm gonna move over to my overrides and let's

22:04.080 --> 22:09.440
click on this apply all and make sure you just make this audio game object as well a prefab.

22:09.440 --> 22:15.240
So we're going to have the copy and we will use this audio game object or all of these things as well

22:15.280 --> 22:17.000
in our mano scene.

22:17.280 --> 22:21.200
Because in mano scene we also want our theme to be play.

22:21.200 --> 22:22.120
So that's why.

22:22.160 --> 22:24.120
So let's head over to our mano scene.

22:24.120 --> 22:28.240
So I'm going to move over to my project tab First Assets and then since folder.

22:28.240 --> 22:32.520
And let's double click on this mano in order to move to that scene.

22:32.520 --> 22:34.640
And let's click on that save button.

22:34.640 --> 22:41.000
So whatever I have done so far inside my sample scene or in which scene we're just playing our game,

22:41.000 --> 22:41.880
it's going to be saved.

22:41.880 --> 22:43.160
So I just want to save.

22:43.160 --> 22:45.760
So that's why I'm going to click on this save button.

22:45.760 --> 22:51.280
And as soon as we click on save, we can see we just headed over to our scene.

22:51.280 --> 22:58.320
And whatever we have done so far inside that sample scene, it just saves a really apologize for, uh,

22:58.360 --> 23:01.920
the car just, uh, passing by next to my home.

23:02.520 --> 23:03.720
I'm really apologize.

23:03.720 --> 23:05.890
And it's just making noises too much.

23:06.170 --> 23:10.810
And let's move over to project tape one more time than assets and then prefabs folder.

23:10.850 --> 23:16.450
Basically I'm going to move over to that folder where I just turned that audio game object as a prefab.

23:16.450 --> 23:18.170
And I can see it over here.

23:18.170 --> 23:23.010
So I'm going to select that one and let's drag it over to this hierarchy as well as you can drag it

23:23.010 --> 23:24.730
in the scene view as well.

23:24.770 --> 23:26.890
I'm going to drag it over to my hierarchy.

23:27.210 --> 23:29.610
And let's click on this play button by now.

23:29.610 --> 23:30.970
So it should be fine.

23:30.970 --> 23:37.810
So as soon as our menu is going to load up that theme or the music just going to play right away because

23:37.810 --> 23:39.770
we just have done the thing there.

23:40.370 --> 23:41.770
So let's have a look on it.

23:42.770 --> 23:51.250
And we can see as soon as we just, uh, the menu just loaded up that theme or that sound just plays

23:51.250 --> 23:51.970
right away.

23:51.970 --> 23:58.450
I hope you get the idea that how you can add audio to your game, and we need to press down control

23:58.490 --> 24:00.850
S in order to save our project.

24:00.850 --> 24:03.850
So I'm going to press down control S to save my project.

24:03.850 --> 24:04.930
And it's done.
