WEBVTT

00:06.970 --> 00:08.200
Welcome back.

00:08.620 --> 00:15.880
So now we have the ability to know when we've had an effect applied to us, such as when picking up

00:15.880 --> 00:20.680
one of our pickups and we know which gameplay tags those pickups have.

00:20.710 --> 00:28.090
In the case of our mana potion, we have two gameplay tags in that gameplay effect.

00:28.330 --> 00:33.700
Specifically, we're accessing the asset tags in the gameplay effect.

00:33.850 --> 00:38.890
These are tags that are not given to the actor that the gameplay effect is applied to.

00:38.890 --> 00:45.400
They're just carried along in the gameplay effect and we're retrieving them and we're sending them over

00:45.400 --> 00:47.080
to our widget controller.

00:47.080 --> 00:54.550
So back in Writer, we can see right here where we're taking the ability system component Member On

00:54.550 --> 01:01.360
our overlay widget controller, we're casting that to an aura ability system component and we're getting

01:01.360 --> 01:07.190
the effect asset tags delegate that we created and we're adding a lambda to it.

01:07.190 --> 01:12.650
So we created this lambda, which is an anonymous function that doesn't even have a name.

01:12.650 --> 01:18.800
It's not a member function, it's just an anonymous function that has its own body here and its own

01:18.800 --> 01:20.240
input parameters.

01:20.270 --> 01:26.000
The only input parameters it takes is a const reference to a gameplay tag container, and we're looping

01:26.000 --> 01:29.110
through that and printing a message to the screen.

01:29.120 --> 01:30.620
That's all we're doing so far.

01:31.010 --> 01:38.810
Now we'd like to take those gameplay tags and do something with them and broadcast some information

01:38.810 --> 01:41.750
that our widgets can receive.

01:41.780 --> 01:49.010
Now, rather than just broadcasting a gameplay tag up to the widget side of things, I'd like to have

01:49.010 --> 01:57.550
some kind of asset that we can use to look up information that we can broadcast to the widgets.

01:57.560 --> 02:06.050
For example, we may have a asset such as a data table that can look things up by tag, by gameplay

02:06.050 --> 02:13.590
tag and retrieve some kind of information, some kind of struct that we can pass up to the widgets.

02:13.610 --> 02:22.400
So I'd like to make a data table that has information related to gameplay tags specifically for showing

02:22.430 --> 02:24.020
messages to the screen.

02:24.020 --> 02:31.220
And this data table is going to have its row structure defined here in C plus plus we can define the

02:31.220 --> 02:37.400
row structure as a struct in C plus plus, and I'd like to do that in our overlay widget controller

02:37.400 --> 02:38.360
header file.

02:38.360 --> 02:40.520
So I'm going to go over to that header file.

02:40.520 --> 02:46.790
And up here at the top I'm going to make a struct that will be our row structure.

02:46.790 --> 02:49.070
So we need to give this a name.

02:49.070 --> 02:57.200
So we're going to say struct and I'll call this f UI widget and it's a row structure, so I'm going

02:57.200 --> 03:05.720
to call it f UI widget row and it's going to inherit from the F table row base struct.

03:06.500 --> 03:11.300
That's the base class for a row structure for data tables.

03:11.480 --> 03:15.740
Now it's going to be a UI struct, so we'll give it the use struct macro.

03:16.040 --> 03:22.460
I'm going to make it blueprint type so we can use it as a type in blueprints and it needs the generated

03:22.460 --> 03:23.600
body macro.

03:23.960 --> 03:31.040
Now this row structure that we'll use in our data asset is going to obviously need a gameplay tag.

03:31.040 --> 03:35.480
So I'm going to make an F gameplay tag and call this asset tag.

03:37.670 --> 03:42.500
Now, this is going to be specifically for messages to display to the screen.

03:42.710 --> 03:46.430
So we could call this message tag if we wanted to do that.

03:46.430 --> 03:48.050
In fact, let's do it.

03:48.410 --> 03:52.490
And we're going to make this a new property edit anywhere.

03:56.140 --> 04:01.930
And we'll go ahead and make it Blueprint read only or blueprint read, write.

04:01.930 --> 04:05.590
Either one is fine and we'll make sure these are all initialized.

04:05.590 --> 04:09.010
So I'll initialize it to an empty gameplay tag.

04:09.400 --> 04:10.960
So there's the tag.

04:10.960 --> 04:14.410
We're also going to want a message to display.

04:14.410 --> 04:22.870
And in the realm of widgets, when we display text to the user in the form of a widget, we use text

04:22.870 --> 04:26.920
that's user facing text that we show in widgets.

04:27.100 --> 04:30.010
I'm going to make an F text called Message.

04:30.760 --> 04:37.300
We'll initialize this to an F text and we'll give all of these the same view property.

04:37.720 --> 04:44.410
Now in this data table, I'd like to have a widget class that we can show to the screen.

04:44.410 --> 04:52.780
So for any given gameplay tag, there will be a widget that we can create and add to the viewport whenever

04:52.780 --> 04:56.450
we receive this tag in the form of a gameplay effect.

04:56.450 --> 05:05.060
So I'm going to make a subclass of and it's going to be of type you or a user widget because we're going

05:05.060 --> 05:08.450
to only use aura user widgets for this.

05:08.450 --> 05:12.200
I'm going to add the forward declaration for it at the top here.

05:12.200 --> 05:17.660
So there it is and this will be the message widget.

05:18.360 --> 05:21.060
And again, same property.

05:21.690 --> 05:27.690
Now, our message widget may or may not want to have some kind of image associated with our message.

05:27.690 --> 05:35.370
Maybe we'd like to show an icon of a health potion, for example, and along with that, have some kind

05:35.370 --> 05:38.310
of text that says Picked up health Potion.

05:38.430 --> 05:42.900
And really, there could be any other data that we'd like to pass up that we want.

05:42.930 --> 05:50.760
If we wanted to harvest more data, such as the magnitude of the modifier, whatever we want, you can

05:50.760 --> 05:57.150
put anything in here, but I'm just going to have an image that could be optional and it's going to

05:57.150 --> 05:59.490
be a new texture 2D.

06:00.330 --> 06:08.610
We'll call this image and initialize it to a null pointer and give this a new property as well.

06:09.320 --> 06:11.360
And I think that's enough info for now.

06:11.360 --> 06:12.320
We'll just use this.

06:12.350 --> 06:18.010
We can always add more to this if we find that we need more information in this data table.

06:18.020 --> 06:22.730
But now we have a row structure we can use in a data table.

06:22.940 --> 06:30.020
Now I have my editor running, so I'm going to go ahead and close it down and launch the editor from

06:30.020 --> 06:30.680
here.

06:30.710 --> 06:32.540
So we get a fresh compile.

06:34.830 --> 06:35.310
Okay.

06:35.310 --> 06:36.540
So back in the editor.

06:36.570 --> 06:45.870
Now I'm going to make a data table and I'd like to go into my blueprints folder into UI, and here in

06:45.870 --> 06:49.710
the UI folder, I'm going to make a new folder called Data.

06:49.710 --> 06:56.850
And that way any data tables or perhaps data assets, anything related to data can come here and I'm

06:56.850 --> 06:59.940
going to right click and make a new data table.

06:59.940 --> 07:03.510
So I'll go to miscellaneous and choose data table.

07:03.510 --> 07:11.850
And for the row structure I have to choose my structure that I created called UI, Widget Row and the

07:11.850 --> 07:15.360
F is gone here in the editor, so it's just UI widget row.

07:15.390 --> 07:24.300
I'm going to select it, click okay and call this DBT for data table and this can be our message widget

07:24.300 --> 07:25.230
data.

07:25.230 --> 07:34.120
So we're going to say message widget data and we'll open it up and here we can add a new row and we

07:34.120 --> 07:41.470
can give it a name, it can be associated with a tag, we can choose a tag here, we can set the message

07:41.470 --> 07:46.030
here, we can set a widget and an image, all that stuff.

07:46.030 --> 07:46.950
It's all there.

07:46.960 --> 07:48.700
So I'm going to save that.

07:48.700 --> 07:50.620
I'm not going to fill in any data.

07:50.620 --> 07:55.090
But what we do need are some message tags for any messages.

07:55.120 --> 08:01.630
And right now we have four types of pickups, so we can make some message gameplay tags and we can do

08:01.630 --> 08:03.490
that by going into project settings.

08:03.490 --> 08:10.120
So in project settings we can go to gameplay tags and we can have tags that we add here.

08:10.120 --> 08:16.480
We can even make a new data table for those tags if we wanted to do that, I leave it up to you, but

08:16.480 --> 08:19.660
I'd like a new type of gameplay tag.

08:19.660 --> 08:25.000
I'm going to add new gameplay tag here and this will be message dot.

08:25.440 --> 08:27.120
Health potion.

08:27.360 --> 08:30.270
So I'll have a message health potion.

08:30.270 --> 08:32.160
And that's going to add that here.

08:32.460 --> 08:37.770
And I'd like to add more messages, one for each type of pickup we have.

08:37.800 --> 08:44.520
So next to message, I'm going to click add sub tag and that gives me message dot and I'm going to have

08:44.520 --> 08:46.560
message dot mana potion.

08:47.530 --> 08:51.100
That gives me the mana potion and we'll do another couple of these.

08:51.100 --> 08:54.910
We'll have message dot health crystal.

08:55.420 --> 09:01.000
And once again we'll click it again and have message dot mana crystal.

09:02.020 --> 09:07.090
And now we have four new gameplay tags under the message parent tag.

09:07.210 --> 09:08.590
Okay, great.

09:08.920 --> 09:17.530
So now that we have this, we need a way to let our widgets know or at least our overlay know when our

09:17.530 --> 09:23.590
widget controller has received a message tag so we can go into our overlay.

09:23.590 --> 09:32.770
And here's WB overlay here we have our widget controller and we can bind to delegates on the widget

09:32.770 --> 09:37.510
controller that we may wish to broadcast up here into the blueprint realm.

09:37.510 --> 09:45.010
And if we go back into our widget controller C plus plus code overlay, widget controller CP right here

09:45.010 --> 09:53.720
is where we're binding our lambda to whenever we receive a tag container that's associated with a given

09:53.720 --> 09:54.530
effect.

09:54.560 --> 10:03.020
So once we receive this tag container, we can see if any of those tags have the message parent tag.

10:03.170 --> 10:11.120
And if they do well, then we can look up something from a data table, which means since we have a

10:11.120 --> 10:18.740
new data table that has those assets in UI slash data right here, message data table.

10:18.740 --> 10:25.490
I'd like to have a variable of this type on my widget controller and that way we can always look up

10:25.490 --> 10:30.710
from this table to get any assets that we want to broadcast to the widgets.

10:30.710 --> 10:35.840
So that's the last thing I'm going to do in this video is close out of the editor and we're going to

10:35.840 --> 10:42.530
add a variable to our widget controller, our overlay widget controller class for the data table.

10:43.190 --> 10:45.910
So we'll make this a protected variable.

10:45.920 --> 10:50.840
We'll go down to the protected section and above our function callbacks.

10:51.520 --> 10:59.350
I'm going to have my data table t object pointer and this will be simply a U data table.

11:00.700 --> 11:06.460
And we're going to call this message widget data table.

11:06.850 --> 11:10.960
And I want to be able to set this from my widget controller's blueprint.

11:10.960 --> 11:14.320
So I'm going to make a uproperty macro for it.

11:14.320 --> 11:21.010
Edit Defaults only we can make it edit anywhere, but really we're only going to be editing the defaults

11:21.400 --> 11:23.800
as we just have a default blueprint.

11:23.950 --> 11:29.890
There's only going to be one of these in existence, but I would like to expose to blueprint event graph,

11:29.890 --> 11:37.870
so I'll make it blueprint read only and I'll give it the category of widget data.

11:38.110 --> 11:41.620
So we'll have a data table we can set here.

11:41.620 --> 11:49.600
And then once we receive any gameplay tags from events here in our lambda, we can perform some kind

11:49.600 --> 11:55.210
of lookup and broadcast data from that data table up to the widgets.

11:55.210 --> 11:58.060
So I'm going to go ahead and compile and run.

11:58.510 --> 12:00.200
We can hit, run or debug.

12:00.200 --> 12:01.250
Either one is fine.

12:01.850 --> 12:08.450
And I'm just going to set the widget data table for our widget controller.

12:08.450 --> 12:14.540
So I'm going to go to Blueprints, UI, widget Controller and open my overlay widget controller.

12:14.570 --> 12:16.100
There's my variable.

12:16.100 --> 12:22.630
I can expand the dropdown and we have a message widget data.

12:22.640 --> 12:29.690
I'm going to set that as the message widget data table, and now we can access that and we can perform

12:29.690 --> 12:31.790
the lookup and cplusplus.

12:31.790 --> 12:34.250
So we'll be doing that next.

12:34.250 --> 12:39.890
I'll go ahead and close project settings and I'll see you in the next video.
