﻿1
00:00:04,200 --> 00:00:05,670
‫Hey, welcome back.

2
00:00:05,700 --> 00:00:12,630
‫In the last video, we learned a few new property specifiers that allow us to expose our C++ variables

3
00:00:12,630 --> 00:00:16,110
‫in certain ways to the details panel in the blueprints.

4
00:00:16,110 --> 00:00:22,260
‫In this video, we're going to learn some more specifiers that allow us to have more control over access

5
00:00:22,260 --> 00:00:23,430
‫to those variables.

6
00:00:23,430 --> 00:00:29,400
‫In the details panel, we're also going to talk about how we can allow, read or write access in the

7
00:00:29,400 --> 00:00:33,330
‫actual event graph for a particular C++ variable.

8
00:00:33,330 --> 00:00:34,860
‫So let's dive right in.

9
00:00:35,310 --> 00:00:35,820
‫Okay.

10
00:00:35,820 --> 00:00:41,640
‫So I'm back here in VS code and here are the variables we created in the last video.

11
00:00:41,670 --> 00:00:44,130
‫Now here is my speed variable.

12
00:00:44,130 --> 00:00:45,900
‫This was for the challenge.

13
00:00:45,900 --> 00:00:51,510
‫You probably created a different variable, which is totally fine, so keep that variable there.

14
00:00:51,510 --> 00:00:53,880
‫We're going to do some more things with it in this video.

15
00:00:53,880 --> 00:00:59,760
‫Now we've learned that we can make a variable visible anywhere, and when we say anywhere, we mean

16
00:00:59,760 --> 00:01:04,110
‫on the details panel, either on an instance or on the default blueprint.

17
00:01:04,140 --> 00:01:11,550
‫We saw that we can also make it edit anywhere, and when we use visible instance only, it's only visible

18
00:01:11,580 --> 00:01:12,600
‫on an instance.

19
00:01:12,600 --> 00:01:17,430
‫You can't even see it on the default blueprint and in any case, you can't edit it because it's grayed

20
00:01:17,430 --> 00:01:17,820
‫out.

21
00:01:17,820 --> 00:01:21,330
‫So this allows us to make our variable visible only on the instance.

22
00:01:21,330 --> 00:01:25,080
‫But what if we'd like it to be visible only on the default blueprint?

23
00:01:25,080 --> 00:01:27,360
‫Well, there's a specifiers for that too.

24
00:01:27,390 --> 00:01:34,560
‫Let's make another in 32 and let's call this visible defaults only int.

25
00:01:35,210 --> 00:01:37,520
‫And we can initialize this to a value.

26
00:01:37,520 --> 00:01:41,930
‫I'm going to give it five and we'll give this a U property as well.

27
00:01:41,930 --> 00:01:45,640
‫And the specify are for making this visible only on the defaults.

28
00:01:45,650 --> 00:01:47,780
‫You can probably guess what it is.

29
00:01:47,780 --> 00:01:50,810
‫It's visible defaults only.

30
00:01:50,810 --> 00:01:56,960
‫So I'm going to compile this and back here in the editor, I'm going to open up BP Pond Tank again.

31
00:01:56,960 --> 00:02:02,210
‫And with BP Pond Tank self-selected, all of our variables are up here at the top, so I'm not going

32
00:02:02,210 --> 00:02:03,170
‫to search for it.

33
00:02:03,170 --> 00:02:09,620
‫But here's our visible defaults only int and it's got the value five and of course it's grayed out now

34
00:02:09,620 --> 00:02:12,500
‫as the name suggests, it's visible only on the default.

35
00:02:12,500 --> 00:02:19,370
‫So if I go in the world and select one of the instances of BP pond tank here, there is no visible defaults

36
00:02:19,370 --> 00:02:23,540
‫only int it's not visible on the instance, only on the default.

37
00:02:23,540 --> 00:02:25,100
‫So that makes sense right now.

38
00:02:25,100 --> 00:02:30,860
‫Let's go back into VS code and we have a few more specifiers to learn about.

39
00:02:30,890 --> 00:02:36,680
‫Now we've seen that we can edit anywhere and that with our visible specifiers we can choose instance

40
00:02:36,680 --> 00:02:38,360
‫only or default only.

41
00:02:38,360 --> 00:02:45,710
‫So as you've probably guessed, we can edit on only the instance or only the defaults if we choose.

42
00:02:45,710 --> 00:02:48,140
‫So let's make a couple more in 30 twos.

43
00:02:48,140 --> 00:02:55,310
‫I'm going to make one called edit defaults only int and initialize that to a value say nine and then

44
00:02:55,310 --> 00:03:00,020
‫another int 32 called edit instance only int.

45
00:03:00,020 --> 00:03:02,600
‫And I'll give this a value of 14.

46
00:03:02,600 --> 00:03:09,740
‫So we want edit defaults only int to be editable only on the defaults and edit instance only and to

47
00:03:09,740 --> 00:03:11,900
‫be editable only on the instance.

48
00:03:11,900 --> 00:03:17,870
‫Now the names of these specifiers are pretty consistent, so I'd like you to just guess what the specifiers

49
00:03:17,870 --> 00:03:20,360
‫would be for these two access levels.

50
00:03:20,390 --> 00:03:23,150
‫Go ahead and just do a quick little mini challenge.

51
00:03:23,150 --> 00:03:26,330
‫Pause the video and fill these in, see if you're right.

52
00:03:29,030 --> 00:03:32,570
‫Okay so these are going to be you properties and edit defaults.

53
00:03:32,600 --> 00:03:35,600
‫Only end is going to get you probably guessed it.

54
00:03:35,600 --> 00:03:44,060
‫Edit defaults only and for edit instance only int I'll give this a u property macro and this will be

55
00:03:44,060 --> 00:03:46,400
‫edit instance only.

56
00:03:46,400 --> 00:03:47,810
‫So it's pretty intuitive.

57
00:03:47,840 --> 00:03:54,530
‫Let's go ahead and compile these and back here in the editor with BP -- tank open here's our edit

58
00:03:54,530 --> 00:04:01,100
‫defaults only int we don't see edit instance only and we didn't expect to it's set to nine here we can

59
00:04:01,100 --> 00:04:08,090
‫change it and if we go into the world with one of our instances selected we can see edit instance only

60
00:04:08,090 --> 00:04:10,790
‫int and of course that's editable as well.

61
00:04:10,970 --> 00:04:14,840
‫So we've now added three new specifiers to our graph here.

62
00:04:14,840 --> 00:04:21,020
‫We have visible defaults only, which is in only the default column and in the read only row.

63
00:04:21,050 --> 00:04:26,450
‫And then we have edit defaults only and edit instance only in their respective rows.

64
00:04:26,600 --> 00:04:31,880
‫So we're filling up this graph pretty quickly, but you'll notice that there are a couple of spaces

65
00:04:31,880 --> 00:04:35,840
‫empty over there to the right and the event graph column.

66
00:04:35,840 --> 00:04:38,300
‫So let's talk about these for a minute now.

67
00:04:38,300 --> 00:04:45,230
‫I'm here in BP Pond Tank, and we have all of these variables that we've exposed to the details, panels,

68
00:04:45,410 --> 00:04:47,030
‫depending on their specifiers.

69
00:04:47,060 --> 00:04:49,370
‫You can see them here or on an instance.

70
00:04:49,370 --> 00:04:52,010
‫But what if I right click here in the event graph?

71
00:04:52,040 --> 00:04:57,440
‫The event graph is another place where we can access variables and potentially change them.

72
00:04:57,440 --> 00:05:02,150
‫So if I type edit anywhere, I do not see the edit anywhere.

73
00:05:02,150 --> 00:05:05,090
‫INT it's not exposed to the event graph.

74
00:05:05,090 --> 00:05:06,860
‫We don't have access to that.

75
00:05:06,860 --> 00:05:13,460
‫There is another specifiers that allows us to expose things here in the event graph and that can work

76
00:05:13,460 --> 00:05:18,800
‫in conjunction with the specifiers that control the details panel accessibility.

77
00:05:18,800 --> 00:05:23,150
‫And I'd like to expose one of these variables to the event graph.

78
00:05:23,150 --> 00:05:26,870
‫Now, I could choose any one of these, but I'm going to choose this visible anywhere.

79
00:05:26,870 --> 00:05:27,830
‫INT Now the U.

80
00:05:27,830 --> 00:05:32,630
‫Property macro can take multiple inputs, so we have visible anywhere.

81
00:05:32,630 --> 00:05:34,010
‫We can still have that.

82
00:05:34,010 --> 00:05:39,920
‫I'm going to place a comma and I'd like to add another specified to that will give this visible anywhere

83
00:05:39,920 --> 00:05:42,680
‫end exposure to the event graph.

84
00:05:42,680 --> 00:05:48,650
‫So what I'm going to use is blueprint read, write, blueprint read.

85
00:05:48,650 --> 00:05:51,230
‫Write has to do with the event graph.

86
00:05:51,350 --> 00:05:54,500
‫It has nothing to do with control over the details panel.

87
00:05:54,500 --> 00:05:57,140
‫That's what this visible anywhere is for.

88
00:05:57,140 --> 00:06:02,570
‫So Blueprint Rewrite does, as the name suggests, read access and write access.

89
00:06:02,570 --> 00:06:04,240
‫So let's see how that looks.

90
00:06:04,250 --> 00:06:11,030
‫Let's compile this and I'm back here in the editor in the event graph if I right click and type visible

91
00:06:11,030 --> 00:06:11,960
‫anywhere.

92
00:06:12,660 --> 00:06:18,630
‫We'll see two different options get visible anywhere int and set visible anywhere.

93
00:06:18,630 --> 00:06:21,330
‫INT If you select, get visible anywhere.

94
00:06:21,330 --> 00:06:27,690
‫INT We get a node and this is just like any other blueprint node, it represents that C++ variable and

95
00:06:27,690 --> 00:06:32,430
‫if we drag off of this, we can access that value to do something with it.

96
00:06:32,430 --> 00:06:38,400
‫Now I'm going to scroll out and you'll see that we have these grayed out nodes actor begin, overlap

97
00:06:38,400 --> 00:06:43,500
‫and event tick and Begin Play is called at the beginning of the game as you know.

98
00:06:43,500 --> 00:06:45,120
‫So we can do something here.

99
00:06:45,120 --> 00:06:51,750
‫I'd like to use a print string node and if I drag off and type print string, then here it is.

100
00:06:51,750 --> 00:06:57,750
‫It's a blueprint function node and it takes a input called in string.

101
00:06:57,750 --> 00:07:02,250
‫Now if I hover over it, it says in string and then string right below that.

102
00:07:02,250 --> 00:07:05,940
‫That's the type that this node accepts as an input parameter.

103
00:07:05,940 --> 00:07:10,260
‫And we know that our visible anywhere int is an int 32, not a string.

104
00:07:10,260 --> 00:07:17,400
‫But if you click from the output of this note and drag and stick it right here in the input before you

105
00:07:17,400 --> 00:07:23,370
‫release the left mouse button, you see a pop up that says convert integer to string and if you release

106
00:07:23,370 --> 00:07:29,850
‫then you get this handy conversion node that converts from an integer to the string type, which is

107
00:07:29,850 --> 00:07:34,650
‫very handy for us because we don't have to figure out how to convert an integer to a string.

108
00:07:34,650 --> 00:07:36,480
‫It's just automatic for us.

109
00:07:36,510 --> 00:07:42,540
‫Now, if I hit play, we'll see the value 12 printed three times and it only lasts for a few seconds.

110
00:07:42,540 --> 00:07:44,430
‫That's the behavior of print string.

111
00:07:44,430 --> 00:07:50,550
‫Now, the reason we see it three times is because I have three different instances of BP pond tank here

112
00:07:50,550 --> 00:07:51,330
‫in the world.

113
00:07:51,330 --> 00:07:54,900
‫Depending on how many you've dragged into the world, you'll see that many.

114
00:07:54,900 --> 00:08:00,210
‫Because for each of these individual instances, begin play is getting called at the beginning of the

115
00:08:00,210 --> 00:08:00,630
‫game.

116
00:08:00,630 --> 00:08:06,180
‫So just to avoid confusion, I'm going to just delete my other two and just leave a single instance

117
00:08:06,180 --> 00:08:08,220
‫of Beep Pond Tank here in the world.

118
00:08:08,220 --> 00:08:15,270
‫So I have only one and if I go and hit play again then I see 12 printed to the screen only once.

119
00:08:15,270 --> 00:08:21,840
‫So that is read access to visible anywhere int but we saw that we also have write access.

120
00:08:21,840 --> 00:08:24,960
‫That means we can set its value from here in the event graph.

121
00:08:24,960 --> 00:08:32,220
‫So if I right click and type visible anywhere int again then I can select set visible anywhere int and

122
00:08:32,220 --> 00:08:38,850
‫I have a setter node which takes an input we can pass in the value from some other node or we can take

123
00:08:38,850 --> 00:08:42,900
‫this little text box and hard code of value, say 66.

124
00:08:42,900 --> 00:08:48,660
‫And now as soon as the flow of execution from begin play reaches this node, then the setter node is

125
00:08:48,660 --> 00:08:54,480
‫going to write to visible anywhere and it's going to set its value to 66.

126
00:08:54,480 --> 00:08:56,610
‫And of course we can print this out again.

127
00:08:56,610 --> 00:08:58,590
‫So I'm going to use print string.

128
00:09:00,070 --> 00:09:05,700
‫And for the value passed into print string, I'd like the value of visible anywhere int.

129
00:09:05,710 --> 00:09:07,720
‫Now I can do this one of two ways.

130
00:09:07,720 --> 00:09:13,990
‫The setter has a return node, so after it set the value, then it returns that value and we can use

131
00:09:13,990 --> 00:09:16,990
‫it so we can plug it straight in to print string.

132
00:09:16,990 --> 00:09:23,770
‫The other way is to simply right click and get visible anywhere int use that get node and we can hook

133
00:09:23,770 --> 00:09:29,470
‫up the value from this node right into print string that would do the exact same thing.

134
00:09:29,470 --> 00:09:30,700
‫So I don't need that.

135
00:09:30,700 --> 00:09:31,960
‫I'm going to delete that node.

136
00:09:31,960 --> 00:09:38,680
‫And now what I'm expecting to see when I play the game is to first print out the value of visible anywhere

137
00:09:38,680 --> 00:09:46,480
‫int, which starts off at 12 and then after setting its value to 66, I should see the value 66 print

138
00:09:46,480 --> 00:09:47,320
‫it out to the screen.

139
00:09:47,320 --> 00:09:50,560
‫So let's hit play and we see 12 and 66.

140
00:09:50,560 --> 00:09:52,540
‫Now they look like they're in reverse order.

141
00:09:52,540 --> 00:09:56,170
‫That's because print string adds newer messages on top.

142
00:09:56,170 --> 00:09:58,270
‫So that is normal behavior.

143
00:09:58,270 --> 00:09:59,110
‫Okay, great.

144
00:09:59,110 --> 00:10:02,800
‫So we've seen that we can make a variable blueprint read right now.

145
00:10:02,800 --> 00:10:07,210
‫We can also control whether or not we can set this from the event graph.

146
00:10:07,210 --> 00:10:13,450
‫So let's expose another variable so that we can get it from blueprints but not set it here's edit anywhere.

147
00:10:13,450 --> 00:10:20,080
‫INT I'm going to add a comma and add a specified to to this now in order to access it in the event graph

148
00:10:20,080 --> 00:10:22,930
‫but not be able to set it or write to it.

149
00:10:22,930 --> 00:10:30,520
‫The specify hour is blueprint read only so edit anywhere int is now blueprint read only.

150
00:10:30,520 --> 00:10:37,570
‫It's still editable in the details panel, both in the default and on instances, but in the event graph

151
00:10:37,570 --> 00:10:38,470
‫it's read only.

152
00:10:38,470 --> 00:10:44,080
‫So let's go ahead and compile this and back here in the editor, I'm going to right click in the event

153
00:10:44,080 --> 00:10:47,080
‫graph and type edit anywhere and check it out.

154
00:10:47,080 --> 00:10:53,050
‫We have get edit anywhere end but we do not have a set edit anywhere int because it's blueprint read

155
00:10:53,050 --> 00:10:55,240
‫only, we cannot write to it.

156
00:10:55,240 --> 00:10:56,650
‫So I'm going to select it.

157
00:10:56,650 --> 00:10:57,910
‫Here's edit anywhere.

158
00:10:57,910 --> 00:11:03,250
‫INT And if I wanted to I could use a print string node to see its value.

159
00:11:03,280 --> 00:11:04,360
‫No need to do that.

160
00:11:04,360 --> 00:11:05,680
‫We already know how to do that.

161
00:11:05,680 --> 00:11:09,760
‫I'm just demonstrating that we cannot write to this variable.

162
00:11:09,790 --> 00:11:13,630
‫Okay, so I'm going to go ahead and highlight these nodes and delete them.

163
00:11:13,630 --> 00:11:15,880
‫So our graph is now filled out.

164
00:11:15,880 --> 00:11:21,700
‫We've learned that we can make our variables visible only on the defaults and we can make them editable

165
00:11:21,700 --> 00:11:24,550
‫only on the defaults or only on the instance.

166
00:11:24,550 --> 00:11:27,820
‫So we really have full control from the C++ side.

167
00:11:27,850 --> 00:11:34,240
‫Now we also saw that we can expose these variables to the event graph and make them read only or read

168
00:11:34,240 --> 00:11:38,650
‫right using these blueprint read only, blueprint read write specifiers.

169
00:11:38,650 --> 00:11:40,180
‫So now you have a challenge.

170
00:11:40,180 --> 00:11:43,330
‫In the last lecture we created a variable.

171
00:11:43,330 --> 00:11:45,310
‫I made a float and called it speed.

172
00:11:45,340 --> 00:11:46,960
‫Now you're going to take that variable.

173
00:11:46,960 --> 00:11:52,180
‫You create it in the last section and control its access in the event graph.

174
00:11:52,180 --> 00:11:57,700
‫So expose it to the event graph using one of the new specifiers you've learned, and then you're going

175
00:11:57,700 --> 00:12:00,520
‫to test out the read write access for this.

176
00:12:00,520 --> 00:12:06,040
‫Use a print string node so that you can see its value and if you change it, prove to yourself that

177
00:12:06,040 --> 00:12:07,000
‫you've changed it.

178
00:12:07,000 --> 00:12:12,520
‫So if you make your variable blueprint read right, try changing it with a set node and then using a

179
00:12:12,520 --> 00:12:15,880
‫print string node to see its value using event begin play.

180
00:12:15,880 --> 00:12:21,640
‫If you made it blueprint read only then you can simply get the value and print its value using print

181
00:12:21,640 --> 00:12:22,120
‫string.

182
00:12:22,120 --> 00:12:29,080
‫So add the correct specify to your custom variable and use print string to test out access in the event

183
00:12:29,080 --> 00:12:29,590
‫graph.

184
00:12:29,590 --> 00:12:31,780
‫Pause the video and give this a try.

185
00:12:34,570 --> 00:12:34,990
‫Okay.

186
00:12:34,990 --> 00:12:40,330
‫So I'm going to scroll down to my speed variable here and my speed variable is edit anywhere and I'd

187
00:12:40,330 --> 00:12:41,620
‫like it to be blueprint read.

188
00:12:41,620 --> 00:12:44,530
‫Right, so I can change it from within the event graph.

189
00:12:44,530 --> 00:12:49,110
‫So I'm going to add blueprint, read, write and simply compile.

190
00:12:49,120 --> 00:12:55,990
‫So back in BP pond tank, if I type speed now I see the getter and setter for this.

191
00:12:56,110 --> 00:12:58,180
‫So I'm going to use set speed.

192
00:12:58,330 --> 00:13:00,940
‫I'm going to set its value from Begin Play.

193
00:13:00,940 --> 00:13:01,930
‫So let's hook this up.

194
00:13:01,930 --> 00:13:09,640
‫And for the value, I'm going to enter 900 and from the set note if I drag off I can type print string.

195
00:13:09,640 --> 00:13:13,780
‫Now I'm going to click and drag off of the output node, hook it up to string.

196
00:13:13,780 --> 00:13:18,370
‫So if I hit play, there's 900, notice it says 900.0.

197
00:13:18,370 --> 00:13:19,960
‫That's because this is a float.

198
00:13:19,960 --> 00:13:24,190
‫And so it's giving me the courtesy of showing that first decimal point.

199
00:13:24,190 --> 00:13:26,680
‫So that's kind of a nice built in feature here.

200
00:13:26,680 --> 00:13:31,630
‫It's showing me one digit to the right of the decimal point for my speed variable.

201
00:13:31,630 --> 00:13:36,550
‫So in summary, we learned some more specifiers for the new property macro.

202
00:13:36,580 --> 00:13:41,650
‫We learned visible defaults only, edit defaults only and edit instance only.

203
00:13:41,650 --> 00:13:47,110
‫And we also learned how we can control read write access in the event graph with Blueprint, read,

204
00:13:47,110 --> 00:13:48,550
‫write and Blueprint Read.

205
00:13:48,550 --> 00:13:56,350
‫Only the C++ programmer has a great deal of control over what gets exposed and what can be changed in

206
00:13:56,350 --> 00:14:01,060
‫the blueprint and where we'll be using these throughout this section of the course.

207
00:14:01,210 --> 00:14:05,620
‫And you'll continue to use them throughout your career as an unreal engine developer.

208
00:14:06,130 --> 00:14:07,510
‫I'll see you in the next lecture.

