WEBVTT

00:07.320 --> 00:08.500
Welcome back.

00:08.520 --> 00:12.670
Now our beam looks great, but we want it to sound great too.

00:12.690 --> 00:14.810
So we're going to add sound in this video.

00:14.820 --> 00:20.430
But before we do that I'm going to show you one side effect of multiplayer.

00:20.460 --> 00:25.230
Let's go to the number of players and set it to two and press play.

00:25.470 --> 00:27.300
I'm going to put.

00:30.200 --> 00:31.790
The screens on both sides.

00:31.790 --> 00:35.510
Right here I have the server and on the right is the client.

00:35.540 --> 00:39.650
Now on the client notice things are working just fine.

00:39.650 --> 00:42.230
And we see this both on client and server.

00:42.230 --> 00:48.440
But on the server if I right click and hold well notice the server owned character on the client here

00:48.470 --> 00:50.660
does not stay in that shock loop.

00:50.660 --> 00:52.250
It just goes back.

00:52.400 --> 00:58.730
Well that's because that shock loop variable is not replicated and it's used in the animation blueprint.

00:59.060 --> 01:07.940
So if we go to a character and we select in shock loop and we come over to the details panel and under

01:07.940 --> 01:10.280
replication we select replicated.

01:10.310 --> 01:13.070
Now it gets those two white balls there.

01:13.220 --> 01:15.640
It's now a replicated variable.

01:15.650 --> 01:18.220
And now we should be able to see it.

01:20.050 --> 01:21.280
Let's test that.

01:22.900 --> 01:29.910
So on the server I'm going to electrocute and notice on the client we're in the shock loop.

01:29.920 --> 01:30.850
It looks great.

01:32.300 --> 01:34.580
So that's going to take care of that problem.

01:34.580 --> 01:36.590
But it's still silent.

01:37.600 --> 01:39.420
And we want sound, right?

01:39.430 --> 01:47.170
So let's go to our gameplay cue shock loop, go to while active and let's spawn a sound as well.

01:47.200 --> 01:49.360
So I'm going to right click in here.

01:53.300 --> 01:56.810
And I'm going to use spawn sound attached.

01:56.930 --> 02:01.160
Now if we use spawn sound attached, it returns the audio component.

02:01.190 --> 02:04.760
We can hold on to that until we need to remove it.

02:06.140 --> 02:12.920
So I'm going to take its return value and promote it to a variable called shock loop sound.

02:20.380 --> 02:23.770
Now spawn sound attached needs a sound.

02:24.340 --> 02:31.270
We can go into assets, sounds, abilities, shock and use shock loop.

02:31.270 --> 02:32.740
Here's what it sounds like.

02:35.320 --> 02:37.120
I'd like to use that here.

02:37.120 --> 02:38.500
So I'm going to set that.

02:38.920 --> 02:41.800
Now the attach to component.

02:42.280 --> 02:45.130
It doesn't matter what we attach it to.

02:45.130 --> 02:52.420
But just because we can we can attach it to the target attach component which we know is the weapon.

02:52.510 --> 02:55.630
So I'm going to promote that to a variable as well.

02:57.120 --> 03:00.810
And this will be simply target attached component.

03:05.440 --> 03:08.800
And we'll use that for the attach to component.

03:14.950 --> 03:18.970
In fact, we could specifically attach it to the tip socket if we wanted to.

03:19.790 --> 03:25.940
Okay, now I'm going to check stop when attached to destroyed and make sure auto destroy is checked.

03:25.940 --> 03:29.750
And with that, we're spawning the sound and we just need to remove it.

03:29.750 --> 03:30.980
And on remove.

03:31.430 --> 03:38.870
So here in on remove, what I'm going to do is after we've destroyed the Niagara system component,

03:38.900 --> 03:42.890
I'm then going to get my shock loop sound.

03:43.160 --> 03:45.920
I'm going to convert it to a validated get.

03:45.920 --> 03:48.920
And after destroying the component we're going to get it.

03:48.920 --> 03:53.840
But if our beam system is not valid I'm still going to check the shock loop.

03:53.840 --> 03:56.840
So I'm going to reroute the not valid node.

03:57.700 --> 03:59.710
Around my destroy component.

03:59.740 --> 04:01.990
Node and hook that in here too.

04:02.440 --> 04:07.330
Now if we just destroy the sound component, it's going to sound pretty abrupt.

04:07.570 --> 04:10.990
In fact, let's just see what happens if we do that.

04:11.950 --> 04:13.150
I'm going to take it.

04:13.390 --> 04:16.480
And we can call destroy component.

04:20.480 --> 04:22.730
Let's see how this sounds.

04:26.280 --> 04:28.230
So it's kind of abrupt.

04:28.590 --> 04:31.140
I'm going to set the number of players down to one.

04:31.230 --> 04:32.760
Try it on the server.

04:35.600 --> 04:41.270
So notice that the sound is abrupt and I don't like that super abrupt change.

04:41.270 --> 04:46.520
So instead of just destroying the component, I'm going to call a function.

04:47.200 --> 04:49.150
Called Fade Out.

04:50.440 --> 04:55.630
And fade out has a fade out duration and even a fade curve.

04:55.900 --> 05:01.930
Now, if I choose a fade out duration of 0.3, we can see how that sounds.

05:11.530 --> 05:13.000
So it's not so abrupt.

05:13.000 --> 05:18.760
I like that, and if you like, you can choose a different kind of curve for it to fade out like a sign

05:18.760 --> 05:20.140
or an S curve.

05:24.590 --> 05:26.150
I kind of like how that sounds.

05:26.150 --> 05:29.480
So I'm going to leave that at sine curve.

05:29.540 --> 05:36.080
And regardless of whether the shock loop sound is valid or not, we're also going to hit that return

05:36.080 --> 05:36.740
node.

05:37.420 --> 05:38.660
No matter what.

05:38.680 --> 05:42.580
So I'm going to reroute this around and stick it to the return node.

05:42.940 --> 05:45.580
And that's what on remove looks like.

05:46.440 --> 05:51.240
Okay, so now Shock Loop has sound and it sounds pretty awesome.

06:02.690 --> 06:03.410
Awesome.

06:04.010 --> 06:06.260
All right, so things are looking good.

06:06.410 --> 06:07.820
It's not really functional.

06:07.820 --> 06:09.650
We're not causing damage or anything.

06:09.650 --> 06:15.680
So there's still some work to do, but we're making progress and we'll continue to do so in the next

06:15.680 --> 06:16.430
video.

06:16.610 --> 06:17.780
I'll see you soon.
