﻿1
00:00:04,190 --> 00:00:04,640
‫Hey.

2
00:00:04,640 --> 00:00:05,730
‫Welcome back.

3
00:00:05,750 --> 00:00:08,240
‫We're exposing variables to blueprints.

4
00:00:08,240 --> 00:00:12,110
‫And now we'd like to talk about exposing our components.

5
00:00:12,290 --> 00:00:18,350
‫This will allow us to set some of the properties, such as the meshes on our static mesh components,

6
00:00:18,350 --> 00:00:22,160
‫as well as positioning our capsule and projectile spawn point.

7
00:00:22,190 --> 00:00:26,630
‫Now we're back here in VS Code and we have all of our test variables.

8
00:00:26,630 --> 00:00:33,830
‫And before we start going and exposing our private component variables, there's just a couple more

9
00:00:33,860 --> 00:00:36,990
‫you property specific things we need to learn about.

10
00:00:37,010 --> 00:00:43,880
‫For one, all of our test variables are in the public section and a couple of our variables here are

11
00:00:43,880 --> 00:00:50,780
‫exposed to the event graph allowing read access and right access, and these are not allowed in the

12
00:00:50,780 --> 00:00:51,750
‫private section.

13
00:00:51,770 --> 00:00:58,730
‫For example, if I take our visible anywhere int and edit anywhere int and cut these and paste them

14
00:00:58,730 --> 00:01:01,800
‫down here in the private section along with our components.

15
00:01:01,820 --> 00:01:05,090
‫Here's what happens when we attempt to compile here.

16
00:01:05,090 --> 00:01:08,000
‫We see in our terminal a couple of errors.

17
00:01:08,000 --> 00:01:13,760
‫We see blueprint, read, write should not be used on private members and it says the same thing about

18
00:01:13,760 --> 00:01:15,590
‫Blueprint Read only.

19
00:01:15,740 --> 00:01:20,720
‫So what if we want read and write access in the event graph on private members?

20
00:01:20,720 --> 00:01:22,540
‫Well, there's a way to get around this.

21
00:01:22,550 --> 00:01:26,450
‫We can still have access to private variables in the event graph.

22
00:01:26,450 --> 00:01:28,930
‫We have to add another input to the U.

23
00:01:28,940 --> 00:01:31,490
‫Property macro and that input looks like this.

24
00:01:31,490 --> 00:01:41,390
‫We say meta equals parentheses allow private access equals and in quotes true.

25
00:01:41,420 --> 00:01:43,010
‫Now this looks pretty weird.

26
00:01:43,010 --> 00:01:46,580
‫It's sort of a nightmare of syntax, but this is what it looks like.

27
00:01:46,580 --> 00:01:54,530
‫You property macros allow for metadata and metadata is just a fancy word for data that gives information

28
00:01:54,530 --> 00:01:55,510
‫about other data.

29
00:01:55,520 --> 00:02:03,170
‫So we have this meta equals and if we use allow private access equals true, then we can expose these

30
00:02:03,170 --> 00:02:06,200
‫variables to the event graph even though they're private.

31
00:02:06,230 --> 00:02:12,020
‫Now, if you're a stickler and you don't think giving private access to a variable is a very good idea,

32
00:02:12,020 --> 00:02:13,610
‫well, you don't have to do this.

33
00:02:13,610 --> 00:02:19,400
‫This is just another tool in your toolbox that allows us to expose private variables to blueprint.

34
00:02:19,400 --> 00:02:22,790
‫And on the C++ side, these are still private.

35
00:02:22,790 --> 00:02:25,610
‫You still can't access these from other classes.

36
00:02:25,610 --> 00:02:28,610
‫So you have that encapsulation on the C++ side.

37
00:02:28,640 --> 00:02:33,230
‫This just gives you the ability to get these in blueprints and make changes to them.

38
00:02:33,230 --> 00:02:36,320
‫And really in blueprints, it's kind of a different world.

39
00:02:36,320 --> 00:02:41,210
‫Typically, you're not going to expose things to blueprints that someone could go in and change and

40
00:02:41,210 --> 00:02:42,590
‫potentially break the game.

41
00:02:42,590 --> 00:02:44,570
‫But it's useful to know how to do this.

42
00:02:44,570 --> 00:02:52,850
‫So we're going to give this meta allow private access to both visible anywhere, int and edit anywhere.

43
00:02:52,850 --> 00:02:55,010
‫And so let's compile this.

44
00:02:55,070 --> 00:03:00,860
‫And now we see we have a successful compile even though we have blueprint rewrites and blueprint read

45
00:03:00,860 --> 00:03:03,730
‫only on variables in a private section.

46
00:03:03,740 --> 00:03:10,130
‫Now back here in BP Pond Tank in the event graph, I can right click and type edit anywhere and here

47
00:03:10,130 --> 00:03:17,150
‫we see get edit anywhere int we still have access to it and if I search for visible, I see visible

48
00:03:17,150 --> 00:03:20,000
‫anywhere int we can get and set it.

49
00:03:20,000 --> 00:03:25,490
‫Now the last thing I'm going to show you that we can add to you properties is a category notice here

50
00:03:25,490 --> 00:03:26,780
‫in the details panel.

51
00:03:26,780 --> 00:03:32,510
‫These variables we've added are under this category based upon this is the name of the class and that's

52
00:03:32,510 --> 00:03:33,860
‫where they go by default.

53
00:03:33,860 --> 00:03:40,730
‫But notice that we also have other variables inherited by this class and they're each in their own categories.

54
00:03:40,730 --> 00:03:48,890
‫Now we can create our own category for these exposed variables, and we do that by adding category equals.

55
00:03:48,890 --> 00:03:52,100
‫And in quotes we can give this a category.

56
00:03:52,100 --> 00:03:55,880
‫So I could call this super duper variables.

57
00:03:55,880 --> 00:04:00,050
‫Now I'm going to have a comma here because I placed this here in the U.

58
00:04:00,050 --> 00:04:05,180
‫Property macro as one of the inputs, and all of the inputs have to be separated by commas.

59
00:04:05,180 --> 00:04:11,390
‫I'm going to copy this and add it to the U property here for edit anywhere int as well.

60
00:04:11,390 --> 00:04:15,350
‫So now these should be in their own category called super duper variables.

61
00:04:15,350 --> 00:04:19,130
‫Let's compile and back here in the editor, check this out.

62
00:04:19,130 --> 00:04:25,760
‫We have super duper variables and our variables are here and I can right click in the event graph search

63
00:04:25,760 --> 00:04:27,800
‫for super and check it out.

64
00:04:27,800 --> 00:04:30,980
‫We have super duper variables and our variables are here.

65
00:04:30,980 --> 00:04:36,320
‫So this is a nice way to organize our variables and make them a little bit easier to find.

66
00:04:36,320 --> 00:04:40,100
‫So I've added a couple new things to our table here.

67
00:04:40,100 --> 00:04:45,740
‫We can give private access, we can take private variables and still expose them to the event graph

68
00:04:45,740 --> 00:04:47,780
‫with this meta specifiers.

69
00:04:47,780 --> 00:04:53,180
‫And we can also give variables their own category to organize them in blueprints.

70
00:04:53,300 --> 00:04:59,330
‫So now that you know plenty of ways to control the access to our variables in Blueprint, you're going

71
00:04:59,330 --> 00:05:03,710
‫to fill out the you property for the components now decide.

72
00:05:03,770 --> 00:05:05,090
‫Their access levels.

73
00:05:05,090 --> 00:05:11,210
‫You're going to want visible anywhere for these because edit anywhere is not something you want to give

74
00:05:11,210 --> 00:05:12,380
‫to your components.

75
00:05:12,410 --> 00:05:17,090
‫This means you can actually edit that pointer variable and we don't want to change the pointer.

76
00:05:17,120 --> 00:05:19,130
‫It should always point to the object.

77
00:05:19,130 --> 00:05:24,680
‫We construct it in the constructor, but you can also decide whether or not to give them read, write

78
00:05:24,680 --> 00:05:28,310
‫access in the event graph, give them a category.

79
00:05:28,340 --> 00:05:31,370
‫This will allow us to keep our variables organized.

80
00:05:31,400 --> 00:05:35,160
‫Now, if you're going to give them blueprint, read, write, or blueprint read only.

81
00:05:35,180 --> 00:05:41,150
‫You'll need to allow private access with that meta specified to because these are private variables.

82
00:05:41,180 --> 00:05:46,610
‫Now, once you've exposed the components to blueprints, then you can set some properties in the default

83
00:05:46,610 --> 00:05:47,310
‫blueprint.

84
00:05:47,330 --> 00:05:51,200
‫You can give the static mesh components their own static meshes.

85
00:05:51,200 --> 00:05:57,560
‫So set that up in both the -- tank and in the turret blueprint and position the capsule.

86
00:05:57,560 --> 00:06:04,100
‫So it's roughly encompassing the volume of the meshes and position the projectile spawn point, place

87
00:06:04,100 --> 00:06:08,120
‫it at a point that would make sense for projectiles to spawn from.

88
00:06:08,150 --> 00:06:11,990
‫So pause the video and expose our components to blueprint.

89
00:06:15,010 --> 00:06:15,550
‫Okay.

90
00:06:15,550 --> 00:06:20,200
‫So here we are in our private section, and we'd like to expose these components.

91
00:06:20,230 --> 00:06:26,590
‫Now, first, I'm going to give my capsule component visible anywhere, and I'm going to just decide

92
00:06:26,590 --> 00:06:33,310
‫to give this blueprint read only so I can access the capsule comp variable in the event graph, but

93
00:06:33,310 --> 00:06:34,630
‫I cannot set it.

94
00:06:34,660 --> 00:06:40,120
‫Now I'm going to give these the category and for our components here, I'm just going to give it the

95
00:06:40,120 --> 00:06:45,910
‫category components now because I'm using blueprint read only, I'm going to use meta allow private

96
00:06:45,910 --> 00:06:47,470
‫access equals true.

97
00:06:47,500 --> 00:06:49,720
‫So I'm going to put that right there.

98
00:06:49,720 --> 00:06:56,020
‫And for the rest of my components, I'm happy with these same you properties specifiers, so I'm going

99
00:06:56,020 --> 00:06:59,110
‫to give them all the same specifiers.

100
00:06:59,110 --> 00:07:04,510
‫Now I'm going to compile this and back here in the editor, I'm going to click on the viewport so I

101
00:07:04,510 --> 00:07:08,980
‫can actually see what I'm doing here and I can select base mesh.

102
00:07:08,980 --> 00:07:15,430
‫And for the static mesh property, since we're in the -- tank blueprint, I'm going to choose tank

103
00:07:15,430 --> 00:07:16,300
‫base.

104
00:07:16,450 --> 00:07:18,880
‫That's the base of the tank.

105
00:07:18,910 --> 00:07:24,610
‫Now I can select the turret mesh and for its static mesh I'm going to select tank turret.

106
00:07:24,610 --> 00:07:28,860
‫And now our tank blueprint actually looks like a tank.

107
00:07:28,870 --> 00:07:34,180
‫Now before I set the projectile spawn point, I'd like to adjust the capsule component.

108
00:07:34,180 --> 00:07:37,510
‫So it's roughly encompassing the volume of the mesh.

109
00:07:37,510 --> 00:07:43,660
‫Now with the capsule component selected, we have these properties capsule half height and capsule radius.

110
00:07:43,750 --> 00:07:49,480
‫I'm going to scale the radius and the capsule half height just so that this is looking like approximately

111
00:07:49,480 --> 00:07:50,830
‫the correct shape.

112
00:07:51,010 --> 00:07:57,430
‫And I'm going to need to position my tank so that it's down at the bottom because our capsule component

113
00:07:57,430 --> 00:07:58,960
‫is the root component.

114
00:07:58,960 --> 00:08:05,080
‫We have to move all other components relative to the root so I can select the base mesh and move it

115
00:08:05,080 --> 00:08:05,650
‫down.

116
00:08:05,650 --> 00:08:13,450
‫And to get it just right, I can angle my view like this, or I can come up here where it says perspective

117
00:08:13,450 --> 00:08:14,920
‫and select, right?

118
00:08:14,920 --> 00:08:17,350
‫And I'm now in orthographic mode.

119
00:08:17,350 --> 00:08:21,640
‫This place is everything on a plane so I can move things and get them.

120
00:08:21,640 --> 00:08:27,940
‫Just right now I'm going to turn off snapping so I can position this more precisely, and I think that's

121
00:08:27,940 --> 00:08:29,050
‫looking pretty good.

122
00:08:29,140 --> 00:08:34,210
‫Now I'm going to go back into perspective mode so I can see this and make sure everything looks good

123
00:08:34,210 --> 00:08:39,730
‫and I'll select my capsule component and make sure the scale is just right.

124
00:08:39,730 --> 00:08:44,710
‫Now, this may take a little bit of adjusting to get right, but with a few tweaks you can get it looking

125
00:08:44,710 --> 00:08:45,430
‫pretty good.

126
00:08:45,430 --> 00:08:47,200
‫So I'm satisfied with this.

127
00:08:47,200 --> 00:08:50,830
‫Next, I'd like to position the projectile spawn point.

128
00:08:51,040 --> 00:08:57,190
‫I'm going to turn snapping back on and move it up just in front of the barrel here.

129
00:08:57,190 --> 00:08:58,960
‫So this is looking pretty good.

130
00:08:59,110 --> 00:09:04,270
‫Now I'm going to go ahead and save this and now it's time to set BP pond turret.

131
00:09:04,660 --> 00:09:08,950
‫So here in BP pond turret, I'm going to set the base mesh.

132
00:09:08,950 --> 00:09:15,730
‫So let's select the tower base and I'm going to set turret mesh to tower turret.

133
00:09:16,450 --> 00:09:17,410
‫There we go.

134
00:09:17,410 --> 00:09:24,190
‫Now I'm going to scale up the capsule comp and move the base mesh down and just tweak this until I get

135
00:09:24,190 --> 00:09:25,510
‫it just right.

136
00:09:25,510 --> 00:09:33,910
‫And again, I can go into orthographic view and turn off snapping and get this positioned approximately

137
00:09:33,910 --> 00:09:37,360
‫the way I'd like it and go back into perspective.

138
00:09:37,540 --> 00:09:39,130
‫I think that looks pretty good.

139
00:09:39,130 --> 00:09:41,890
‫Now, the last thing is the projectile spawn point.

140
00:09:41,890 --> 00:09:48,640
‫I'm going to turn snapping back on and position it right here in front of the barrel and I'll set the

141
00:09:48,640 --> 00:09:53,080
‫snapping increments to five just so I can position it right in the front there.

142
00:09:53,080 --> 00:09:57,520
‫Now make sure that the projectile spawn point is not too close to the barrel.

143
00:09:57,700 --> 00:10:00,970
‫We're going to be spawning projectiles from this point.

144
00:10:00,970 --> 00:10:06,460
‫And something that's tripped up some students is that their spawn point is too close to the barrel and

145
00:10:06,460 --> 00:10:11,680
‫there's a collision there which can result in complications when spawning projectiles.

146
00:10:11,680 --> 00:10:18,190
‫Now this can be easily solved by making sure the spawn point is a good distance away from the barrel.

147
00:10:18,190 --> 00:10:21,880
‫And we'll polish this up at the very end of this section of the course.

148
00:10:22,270 --> 00:10:25,990
‫Okay, so the last thing I'm going to do is place a few of these in the world.

149
00:10:25,990 --> 00:10:28,900
‫I've already got a BP pond tank here.

150
00:10:28,930 --> 00:10:31,060
‫I'm going to set that down on the ground.

151
00:10:31,240 --> 00:10:35,980
‫And let's drag in a couple instances of BP pond turret.

152
00:10:36,160 --> 00:10:42,700
‫I'm going to place one here and rotate it so it's facing outward and then I'll go ahead and just place

153
00:10:42,700 --> 00:10:44,890
‫one at each corner here.

154
00:10:45,630 --> 00:10:48,420
‫So that they can guard this central structure.

155
00:10:48,870 --> 00:10:52,920
‫And this is looking a little bit more like the finished product.

156
00:10:53,880 --> 00:10:54,960
‫There we go.

157
00:10:55,170 --> 00:11:01,680
‫And of course, if I wanted to, I could view this from the top and in top orthographic mode.

158
00:11:01,680 --> 00:11:04,890
‫I can position these more precisely.

159
00:11:04,890 --> 00:11:08,430
‫But of course, this is a little bit less important in a polished game.

160
00:11:08,430 --> 00:11:10,740
‫You're going to want everything to look just right.

161
00:11:10,890 --> 00:11:13,170
‫Okay, back to perspective mode.

162
00:11:13,200 --> 00:11:15,720
‫This is looking pretty awesome.

163
00:11:15,720 --> 00:11:22,260
‫So referring back to our section plan, we've created our tank and our goal is for it to move throughout

164
00:11:22,260 --> 00:11:22,830
‫the world.

165
00:11:22,830 --> 00:11:25,980
‫So in the lectures to come, we're going to start learning how to do that.

166
00:11:25,980 --> 00:11:31,890
‫So in this lecture we have exposed our components to blueprints and we've set some properties in the

167
00:11:31,890 --> 00:11:34,840
‫blueprints for the tank and for the turret.

168
00:11:34,860 --> 00:11:36,180
‫Excellent progress.

169
00:11:36,210 --> 00:11:37,500
‫I'll see you in the next video.

