﻿1
00:00:04,560 --> 00:00:04,880
‫Hello.

2
00:00:04,900 --> 00:00:05,250
‫Welcome.

3
00:00:05,250 --> 00:00:08,070
‫In this lecture, we are going to be making sounds.

4
00:00:08,070 --> 00:00:12,810
‫So we'll have a muzzle sound and we'll have an impact sound.

5
00:00:13,860 --> 00:00:16,620
‫Let's dive in and see how we're going to do that in the process.

6
00:00:16,620 --> 00:00:22,860
‫We're going to learn how we can attach sounds to other components so they move with them, such as the

7
00:00:22,860 --> 00:00:23,460
‫muzzle.

8
00:00:24,680 --> 00:00:30,290
‫So now that we've got a nice and tidy pull trigger function, it's quite clear where we want to be making

9
00:00:30,290 --> 00:00:31,160
‫sound effects.

10
00:00:31,190 --> 00:00:38,780
‫Now in my game, the only real sound effects I want are on the muzzle flash and on basically the impact.

11
00:00:38,780 --> 00:00:43,700
‫So the places where we're already spawning emitters, I just want to add sound to that.

12
00:00:44,150 --> 00:00:45,740
‫Now that's relatively straightforward.

13
00:00:45,740 --> 00:00:52,280
‫We've done similar things in the past with the gameplay static, so you can do a play sound at location,

14
00:00:52,280 --> 00:00:54,890
‫which is going to play that sound unattached to any object.

15
00:00:54,890 --> 00:00:55,940
‫So it won't be moving around.

16
00:00:55,940 --> 00:00:59,270
‫It will just stay fixed in that location until it's finished.

17
00:00:59,270 --> 00:01:05,990
‫However, we also want to be able to play and attach sound in the same way as we're playing an attached

18
00:01:05,990 --> 00:01:08,240
‫emitter up at the top.

19
00:01:08,240 --> 00:01:10,160
‫And for that, that's fairly straightforward.

20
00:01:10,160 --> 00:01:15,830
‫What we're going to look for, though, is, first of all, we're passing in this type and let's try

21
00:01:15,830 --> 00:01:17,060
‫and understand that a little bit better.

22
00:01:17,060 --> 00:01:23,750
‫So we've got the play sound at location, which takes in the world context, but it also takes in this

23
00:01:23,750 --> 00:01:25,450
‫you sound base.

24
00:01:25,460 --> 00:01:29,150
‫Now why is it a sound base and not just a sound wave?

25
00:01:29,150 --> 00:01:35,750
‫Because if we go over into unreal, go into our asset packs, shoot a game, sound's weapon, assault

26
00:01:35,750 --> 00:01:41,780
‫rifle and mono, you're going to see that if we hover over any of these clips, then the type here is

27
00:01:41,790 --> 00:01:42,800
‫sound wave.

28
00:01:42,800 --> 00:01:47,900
‫And that actually corresponds to a type and unreal called you sound wave.

29
00:01:47,900 --> 00:01:52,700
‫And if we go and have a look at that sound wave class, you can see that it inherits from you sound

30
00:01:52,700 --> 00:01:53,330
‫base.

31
00:01:53,480 --> 00:01:55,280
‫So what is sound base?

32
00:01:55,280 --> 00:01:56,540
‫What else inherits from it?

33
00:01:56,540 --> 00:02:01,580
‫Well, something called an audio cue or sound cue, which we're going to be using in the next lecture,

34
00:02:01,580 --> 00:02:06,050
‫which allows us to do more complicated things with sound waves, such as randomize them and modulate

35
00:02:06,050 --> 00:02:06,860
‫their pitch.

36
00:02:06,860 --> 00:02:13,070
‫So we're not interested in those just yet, but just know that these functions will work just as well.

37
00:02:13,070 --> 00:02:18,200
‫Whether we're passing in a single sound wave or a collection of sound waves gathered together in a sound

38
00:02:18,200 --> 00:02:18,800
‫cue.

39
00:02:18,800 --> 00:02:24,680
‫And that's by virtue of the fact that they take in a sound base which encompasses both of those types.

40
00:02:24,980 --> 00:02:31,370
‫So what's useful is if we go and look through our gameplay statics for the use of sound base, what

41
00:02:31,370 --> 00:02:33,890
‫else can we play a sound with?

42
00:02:34,190 --> 00:02:38,720
‫Well, here there's a spawn sound at location, a slightly different variation on the previous function.

43
00:02:38,720 --> 00:02:42,050
‫You can see here it returns the audio component that it's spawned.

44
00:02:42,050 --> 00:02:43,670
‫We're not interested in that one though.

45
00:02:43,670 --> 00:02:47,060
‫What we are interested in is our spawn sound attached.

46
00:02:47,090 --> 00:02:53,240
‫Now this takes in our sound and then it also takes in a component that we want to attach it to as well

47
00:02:53,240 --> 00:02:57,200
‫as an optional attach point if we're dealing with a skeletal mesh.

48
00:02:57,230 --> 00:02:59,300
‫So that's the one we're going to want to use.

49
00:02:59,300 --> 00:03:00,800
‫So I'm going to go over into our gun.

50
00:03:00,800 --> 00:03:05,750
‫CP And in order to call it, we're going to need a sound to call it with.

51
00:03:05,750 --> 00:03:11,150
‫So we're going to add that to our configuration in the header file where I'm going to add ourselves

52
00:03:11,150 --> 00:03:17,330
‫a new UE property and I'm going to add it just under our muzzle flash called You Sound Base is going

53
00:03:17,330 --> 00:03:21,680
‫to be the type star and it's going to be the muzzle sound like.

54
00:03:21,680 --> 00:03:27,800
‫So now that we can then configure in the editor and I'm going to go over to the gun CP and we're going

55
00:03:27,800 --> 00:03:28,700
‫to spawn.

56
00:03:28,700 --> 00:03:35,480
‫So it's new gameplay statics again and we're going to call Spawn sound attached and we're going to pass

57
00:03:35,480 --> 00:03:40,100
‫in this time instead of the muzzle flash, the muzzle sound, then we've got to attach it to a mesh

58
00:03:40,100 --> 00:03:41,030
‫and to a socket.

59
00:03:41,030 --> 00:03:45,440
‫And actually for that I'm just going to copy both the mesh and the socket from above because we want

60
00:03:45,440 --> 00:03:51,770
‫to be doing it to exactly the same location, essentially having the sound come out of the end of the

61
00:03:51,770 --> 00:03:52,940
‫barrel of our gun.

62
00:03:52,940 --> 00:04:02,330
‫And if go ahead and compile, we should be able to go over to our rifle, BP, and find a new property.

63
00:04:02,330 --> 00:04:07,190
‫Sure enough, when the compile finished, the muzzle sound property popped up here and we can select

64
00:04:07,190 --> 00:04:10,010
‫from the dropdown one of the sound wave files.

65
00:04:10,010 --> 00:04:11,840
‫We don't currently have any sound cues or we do.

66
00:04:11,840 --> 00:04:13,970
‫They come from the engine, but we don't want any of those.

67
00:04:13,970 --> 00:04:20,540
‫We're just going to go with the assault rifle shot and if we go and play, you can see that we are getting

68
00:04:20,540 --> 00:04:23,570
‫the correct sound effect when firing the rifle.

69
00:04:23,580 --> 00:04:26,870
‫It's now time for your challenge to play the sound at location.

70
00:04:26,870 --> 00:04:33,710
‫That is the function you've probably used before to play an impact sound of which we have a few in here.

71
00:04:33,710 --> 00:04:36,920
‫When I did my dropdown, you could see there was the assault rifle shots.

72
00:04:37,220 --> 00:04:43,820
‫But if we also look for assault rifle, we can see that there are these impact concrete sounds as well.

73
00:04:43,820 --> 00:04:45,590
‫So you might want to choose one of those.

74
00:04:45,590 --> 00:04:47,120
‫So you're going to play an impact sound.

75
00:04:47,120 --> 00:04:52,880
‫You're going to use the Le Sound at location from gameplay statics, hook it up and test it out to see

76
00:04:52,880 --> 00:04:55,960
‫that you're getting both of those sounds in your world.

77
00:04:55,970 --> 00:04:57,680
‫Pause the video and have a go.

78
00:04:58,670 --> 00:04:58,970
‫Okay.

79
00:04:58,970 --> 00:04:59,620
‫Welcome back.

80
00:04:59,630 --> 00:05:00,820
‫So let's give this a shot.

81
00:05:00,830 --> 00:05:03,110
‫First things first, let's set up the configuration.

82
00:05:03,110 --> 00:05:08,480
‫So I'm going to mostly copy the configuration from the muzzle sound, put it underneath the impact effect,

83
00:05:08,480 --> 00:05:10,970
‫and I'm going to call it the impact sound.

84
00:05:11,480 --> 00:05:16,820
‫Then what we're going to do is just set it off compiling because we made a change to our head of file

85
00:05:16,820 --> 00:05:18,200
‫and I want it to be quick.

86
00:05:18,230 --> 00:05:23,570
‫Then we're going to go down to where we're spawning our emitter at a location.

87
00:05:23,570 --> 00:05:27,290
‫We're going to do a new new gameplay statics colon, colon.

88
00:05:27,290 --> 00:05:30,380
‫And we're going to be doing a instead of spawn sound attached.

89
00:05:30,380 --> 00:05:32,300
‫It's going to be a play sound at location.

90
00:05:32,300 --> 00:05:33,730
‫We're going to have to give it a world context.

91
00:05:33,750 --> 00:05:34,730
‫I'm going to do a get world.

92
00:05:34,730 --> 00:05:39,380
‫Then we're going to give it the sound that we want it to play, which is going to be the impact sound.

93
00:05:39,380 --> 00:05:44,150
‫And then we need to give it a location to play the sound out, which is going to be the same as the

94
00:05:44,150 --> 00:05:48,680
‫location for doing our particle effect and direction.

95
00:05:48,680 --> 00:05:54,170
‫Doesn't matter in this case because our sound is going to be the same in all directions.

96
00:05:54,170 --> 00:05:59,690
‫Put a semicolon on the end of that line and go and compile it and head over to the beep rifle where

97
00:05:59,690 --> 00:06:02,870
‫we now have the new configuration variable for the impact sound.

98
00:06:02,870 --> 00:06:06,170
‫As I said, there's going to be something with impact concrete in it.

99
00:06:06,170 --> 00:06:11,660
‫So I'm going to go and select number one from that, go ahead and play and try this out.

100
00:06:11,660 --> 00:06:17,030
‫And as you just heard there, we were getting an impact sound when we were hitting something.

101
00:06:17,030 --> 00:06:22,490
‫And if we weren't hitting anything but just shooting, all you were hearing was the rifle muzzle sound.

102
00:06:22,490 --> 00:06:23,540
‫So that's it for this lecture.

103
00:06:23,540 --> 00:06:27,050
‫We've seen how we can spawn a sound attached to an object.

104
00:06:27,050 --> 00:06:32,000
‫The next lecture, we're going to be looking at how we can randomize those sounds so they aren't always

105
00:06:32,000 --> 00:06:34,250
‫exactly the same every time they're played.

106
00:06:34,250 --> 00:06:35,030
‫See, they're.

