﻿1
00:00:04,470 --> 00:00:05,400
‫Hello and welcome.

2
00:00:05,400 --> 00:00:10,830
‫In this lecture, we're going to be firing off these ball bearings from my current location.

3
00:00:10,830 --> 00:00:17,340
‫So wherever I am, it can be used to shoot at objects in our scene and already start to create a bit

4
00:00:17,340 --> 00:00:19,500
‫of wreckage and carnage.

5
00:00:19,500 --> 00:00:21,720
‫Let's dive in and see how we do this.

6
00:00:22,680 --> 00:00:27,210
‫So let's quickly review the project plan as it currently stands.

7
00:00:27,210 --> 00:00:32,700
‫We have already done our playing with physics and spawning our projectiles into the world.

8
00:00:32,700 --> 00:00:39,960
‫Now what is coming up next is that we need to be aiming those projectiles and ideally starting them

9
00:00:39,960 --> 00:00:42,480
‫from wherever we're shooting from.

10
00:00:42,810 --> 00:00:50,610
‫So at the moment when we play the game, that little steel ball drops out, jumps up into the air,

11
00:00:50,640 --> 00:00:51,360
‫of course.

12
00:00:51,630 --> 00:00:54,900
‫But it doesn't isn't affected by where I am.

13
00:00:54,900 --> 00:00:58,620
‫Ideally, this is a kind of first person shooting game.

14
00:00:58,620 --> 00:01:04,380
‫We should be firing these projectiles out of wherever I'm looking from.

15
00:01:04,380 --> 00:01:07,770
‫But what is it that is doing the looking here?

16
00:01:08,130 --> 00:01:12,750
‫Well, let's try and do a little trick that we can do here.

17
00:01:12,750 --> 00:01:14,250
‫It's called ejecting.

18
00:01:14,670 --> 00:01:17,490
‫And the way you do this is by holding F eight.

19
00:01:17,700 --> 00:01:23,610
‫If you type F eight and then fly around, you'll see that I've kind of just stepped out of my body,

20
00:01:23,610 --> 00:01:26,550
‫that sphere there if I select it.

21
00:01:27,120 --> 00:01:31,920
‫So the game is still playing at this point, but I'm allowed to go around and select objects.

22
00:01:31,920 --> 00:01:42,450
‫So what we've got is a object here called a default pawn pa n, which is same as a pawn that you might

23
00:01:42,450 --> 00:01:45,360
‫use in chess and that hence that little icon.

24
00:01:45,630 --> 00:01:51,600
‫And what that means is it's the, the piece, the little piece with which we are playing our game.

25
00:01:51,840 --> 00:01:58,320
‫And it is a representation of physical representation of the player in the game world.

26
00:01:58,680 --> 00:02:05,580
‫However, when I if I go ahead and stop the game either by hitting escape or by hitting the red button

27
00:02:05,580 --> 00:02:13,440
‫in the toolbar, you'll notice there is no such thing as a pawn in my scene, nor if I search my outline.

28
00:02:13,530 --> 00:02:15,240
‫There is nothing called pawn.

29
00:02:15,540 --> 00:02:16,800
‫So what's going on there?

30
00:02:17,070 --> 00:02:25,260
‫In actual fact, unreal is by default spawning that pawn into the scene for us and it is placing it

31
00:02:25,260 --> 00:02:31,200
‫at the location given by an actor in the scene called Player Start.

32
00:02:31,200 --> 00:02:36,750
‫So if you look in the outline for something called Player Start, you will see that there's this object

33
00:02:36,750 --> 00:02:41,640
‫that looks a little bit like a capsule and it has got an icon of a controller and a flag.

34
00:02:41,640 --> 00:02:45,360
‫And what happens is that if I can, I can move that to a different location.

35
00:02:45,360 --> 00:02:49,860
‫If I want my pawn to start in a different place, you can also rotate it.

36
00:02:49,860 --> 00:02:53,940
‫If I want to start in a different rotation and I can go ahead and hit play and verify that that has

37
00:02:53,940 --> 00:02:59,730
‫indeed changed where I start in the game now, why is all of this relevant?

38
00:02:59,730 --> 00:03:06,030
‫It's relevant because the pawn is the thing that we want to get the location of so that we know where

39
00:03:06,030 --> 00:03:08,220
‫to put our little pinballs.

40
00:03:08,220 --> 00:03:10,830
‫So that's what we need to figure out.

41
00:03:10,830 --> 00:03:18,720
‫So let's go over into our minimal default blueprint, our level blueprint, and see if we can somehow

42
00:03:18,720 --> 00:03:23,250
‫get hold of this pawn because we can't get a reference to it.

43
00:03:23,250 --> 00:03:28,080
‫Like we got a reference to the cube because it gets spawned in when we start playing.

44
00:03:28,140 --> 00:03:37,590
‫So let's right click somewhere in an empty space in the event graph and search for PA n and you'll notice

45
00:03:37,590 --> 00:03:42,720
‫that one of the nodes that comes up here is called get player pawn.

46
00:03:42,720 --> 00:03:48,870
‫So if that's not coming up straight away for you, you might need to type, get, play a pawn and then

47
00:03:48,870 --> 00:03:50,550
‫hit enter and bring it in.

48
00:03:50,670 --> 00:03:56,580
‫You'll notice that this is one of those nodes that doesn't have an execution pin, but it does have

49
00:03:56,580 --> 00:03:58,860
‫an input data pin and an output data pin.

50
00:03:58,860 --> 00:04:00,660
‫And now we understand those data pins a little bit better.

51
00:04:00,660 --> 00:04:02,400
‫Let's have a look at what that is.

52
00:04:02,400 --> 00:04:05,940
‫The input data pin, if you hover over it, it says it's an integer.

53
00:04:05,970 --> 00:04:08,250
‫Okay, so it's looking for a whole number.

54
00:04:08,250 --> 00:04:14,250
‫And there is a comment underneath it that says the index in the player controller lists, starting with

55
00:04:14,250 --> 00:04:16,830
‫the local players and then available remote ones.

56
00:04:16,830 --> 00:04:22,710
‫So this is for multiplayer games, seeing as we're a single player game, the index zero is actually

57
00:04:22,710 --> 00:04:27,480
‫what we want index zero denoting the first and only player.

58
00:04:28,230 --> 00:04:31,050
‫And then you can see the return value here is blue.

59
00:04:31,050 --> 00:04:33,570
‫So I'm guessing it's an object by hover over it.

60
00:04:33,570 --> 00:04:36,360
‫You can see that it is a pawn object reference.

61
00:04:36,360 --> 00:04:40,050
‫So it's a pawn object which we know is an actor as well.

62
00:04:40,620 --> 00:04:41,190
‫Okay.

63
00:04:41,190 --> 00:04:45,330
‫So now with this pawn object, what could we do with that?

64
00:04:45,330 --> 00:04:54,480
‫Well, we can drag off of that pin and we can search for what we're looking for is essentially the location

65
00:04:54,480 --> 00:04:56,880
‫of the player pawn.

66
00:04:56,880 --> 00:05:03,350
‫So we can search for location and we can see that there is something called a get access.

67
00:05:03,490 --> 00:05:04,390
‫A location note.

68
00:05:04,390 --> 00:05:05,980
‫Let's go ahead and select that.

69
00:05:06,790 --> 00:05:11,470
‫And now you can see that the input has been connected up to the target, which is the input to this

70
00:05:11,470 --> 00:05:11,890
‫node.

71
00:05:11,890 --> 00:05:15,700
‫And then there's a new return value which is yellow.

72
00:05:15,700 --> 00:05:17,740
‫So it's a vector perfect.

73
00:05:17,740 --> 00:05:23,410
‫This fits with the location that we want in our BFP projectile.

74
00:05:23,800 --> 00:05:29,110
‫So let's have a go at firing these balls from the player location.

75
00:05:29,200 --> 00:05:30,340
‫You're going to.

76
00:05:30,370 --> 00:05:32,200
‫Can you plug in that location?

77
00:05:32,200 --> 00:05:38,110
‫First of all, in the way that I've got it, I've got got a location and it needs to go into the spawn

78
00:05:38,110 --> 00:05:45,160
‫node now and also have a look at changing the impulse so that it travels forward so that we can move

79
00:05:45,160 --> 00:05:48,510
‫around and start shooting at the table and chairs.

80
00:05:48,520 --> 00:05:50,230
‫Pause the video and have a go.

81
00:05:53,900 --> 00:05:54,560
‫Okay.

82
00:05:54,560 --> 00:05:55,490
‫Welcome back.

83
00:05:55,520 --> 00:06:03,770
‫So, first of all, we're going to drag from the return pin of the actor location node in to the input

84
00:06:03,770 --> 00:06:07,730
‫for the spawn actor, which is the spawn transform location.

85
00:06:07,730 --> 00:06:09,500
‫Let's drag that and they're compatible.

86
00:06:09,500 --> 00:06:13,880
‫They're the same color, they're both vectors so we can make that connection.

87
00:06:14,480 --> 00:06:18,260
‫Next up, we said we want to change the impulse direction.

88
00:06:18,260 --> 00:06:20,250
‫At the moment, it's firing straight up.

89
00:06:20,270 --> 00:06:25,910
‫What I want to do instead, I'm going to cut out of the Z and set it to zero.

90
00:06:25,910 --> 00:06:27,560
‫So we've got no upwards force.

91
00:06:27,560 --> 00:06:35,090
‫And instead we know that if we look in our scene, the forwards direction is actually along the x axis.

92
00:06:35,090 --> 00:06:38,720
‫But notice the x axis is actually pointing in the opposite direction.

93
00:06:38,720 --> 00:06:44,990
‫So what we need to do is if we had just put 1000 in, these projectiles are going to fire off backwards.

94
00:06:44,990 --> 00:06:52,820
‫So what we need to do is put in a -1000 and that's going to fire in the opposite direction.

95
00:06:52,820 --> 00:06:57,020
‫So let's go ahead and hit play and see if we can make this happen.

96
00:06:57,020 --> 00:07:02,840
‫So I'm going to hit spacebar and you can see it's now firing out of my nose at the table and chairs

97
00:07:02,840 --> 00:07:08,450
‫and I can get a little bit closer to have that impact, be a little bit more impactful.

98
00:07:08,450 --> 00:07:10,430
‫I think it's still a little bit weak.

99
00:07:10,430 --> 00:07:16,010
‫So I'm going to multiply this all by four and go ahead and hit play.

100
00:07:16,010 --> 00:07:23,720
‫And now we have got ourselves a much more ferocious little pinball that we can fire at objects in our

101
00:07:23,720 --> 00:07:26,150
‫scene and have a little bit of fun with.

102
00:07:26,270 --> 00:07:32,090
‫So the last tweak I want to make is that these balls are a little bit light at the moment.

103
00:07:32,090 --> 00:07:39,860
‫So if we go to our content drawer and double click on the BP projectile, then it will open up the blueprint

104
00:07:39,860 --> 00:07:40,160
‫editor.

105
00:07:40,160 --> 00:07:45,260
‫You'll notice that it's got this restricted view at the moment, so you need to click Open Full Blueprint

106
00:07:45,260 --> 00:07:52,250
‫editor to get back to what we're used to and then click on the viewport tab to see the preview of our

107
00:07:52,250 --> 00:07:53,330
‫ball bearing.

108
00:07:53,330 --> 00:07:58,310
‫Now I'm going to click on the static mesh component over in components, then go to the details pane

109
00:07:58,310 --> 00:08:01,730
‫and have a look for the mass, which I want to override.

110
00:08:01,730 --> 00:08:04,190
‫At the moment it's a mass of 100 kilos.

111
00:08:04,190 --> 00:08:10,070
‫I think I need to make this a little bit heavier, so I'm going to multiply this by ten as a starting

112
00:08:10,070 --> 00:08:12,920
‫point and then we can go ahead and hit play.

113
00:08:12,920 --> 00:08:20,330
‫And now when I shoot things with this ball bearing, they really do react because it is a pretty heavy

114
00:08:20,330 --> 00:08:21,680
‫piece of metal.

115
00:08:21,710 --> 00:08:22,400
‫Great stuff.

116
00:08:22,400 --> 00:08:26,210
‫So this game is actually starting to become a little bit of fun.

117
00:08:26,210 --> 00:08:32,420
‫However, we are not able to fire these ball bearings in any particular direction, only forward and

118
00:08:32,420 --> 00:08:35,300
‫we're going to fix that in the upcoming lectures.

119
00:08:35,300 --> 00:08:36,140
‫I'll see you there.

