WEBVTT

00:06.870 --> 00:08.010
Welcome back.

00:08.130 --> 00:13.140
In this video, we're going to learn another way to initialize our attributes.

00:13.140 --> 00:18.600
So far, we're just calling these init functions, and that's not my preferred way to do it.

00:18.600 --> 00:22.050
And as I mentioned, there are multiple ways to do it.

00:22.080 --> 00:27.690
Now the way that we're going to do it in this video is not my preferred way either, but you should

00:27.690 --> 00:33.450
know about it just because it's an option that's there and that's to initialize the attributes with

00:33.450 --> 00:34.490
a data table.

00:34.500 --> 00:40.740
Now, my preferred method is through a gameplay effect, and that's the method I see most commonly.

00:40.740 --> 00:45.570
But for educational purposes we're going to cover how to do it from a data table.

00:45.570 --> 00:51.990
And to do that, I'd like to add some more attributes to our attributes set because this project is

00:51.990 --> 00:54.450
going to involve more than just health and mana.

00:54.450 --> 01:00.090
So I'm going to open my aura attribute set header file, and before I do that, I'm going to close all

01:00.090 --> 01:07.630
other tabs except for the CPP file and then head on over to the header file and let's just go through

01:07.630 --> 01:10.930
the boilerplate steps to add a few more attributes.

01:10.960 --> 01:16.240
Now these are my vital attributes, at least what I'm calling vital attributes.

01:16.240 --> 01:23.320
So I'm going to add a multi-line comment here that says vital attributes and the attributes that I'd

01:23.320 --> 01:23.830
like to add.

01:23.830 --> 01:27.280
Now I'm going to categorize a little bit differently.

01:27.280 --> 01:35.290
I'm going to call these my primary attributes, and these are going to be my RPG style attributes,

01:35.290 --> 01:38.100
strength, intelligence and what have you.

01:38.110 --> 01:45.970
Now I'm just going to have four primary attributes, and I understand that many RPGs have more than

01:45.970 --> 01:46.780
four.

01:46.780 --> 01:50.680
You can even have less than four primary attributes.

01:50.710 --> 01:57.160
Really, it depends on your design, but I'd like to have four primary attributes and those four primary

01:57.160 --> 02:00.520
attributes are going to be strength.

02:00.520 --> 02:05.860
So I'm going to have an gameplay attribute data called strength.

02:06.600 --> 02:14.130
And I'm going to have the same view property specifiers as my other vital attributes.

02:14.130 --> 02:17.910
Except we're going to need to change a couple things, right?

02:17.940 --> 02:25.630
For one, I want my category to say primary attributes and strength needs its own rep.

02:25.650 --> 02:28.480
Notify called on rep strength.

02:28.500 --> 02:33.120
So I'm just going to type it here even though it doesn't exist yet.

02:33.120 --> 02:36.410
And then I'll make the rep notify in a second.

02:36.420 --> 02:40.640
But I also want to use my attribute accessors macro for strength.

02:40.650 --> 02:45.720
And I'm going to change this to say strength instead of health.

02:46.050 --> 02:48.750
And I'll go ahead and make my rep notify.

02:49.050 --> 02:51.060
I'm just going to copy one of the others.

02:52.280 --> 02:56.570
Paste it here and call this on rep strength.

02:57.490 --> 03:03.190
And its input will be old strength and I'm going to generate the definition.

03:04.150 --> 03:08.980
And use the same macro gameplay attribute rep notify.

03:09.670 --> 03:15.460
It's going to be the strength attribute and it's going to take in old strength as well.

03:15.820 --> 03:16.420
Okay.

03:16.420 --> 03:19.210
That's not the only thing we need to do, is it?

03:19.240 --> 03:21.590
We also have a couple other steps.

03:21.610 --> 03:27.890
One of those is to go all the way up to get lifetime replicated props and add strength.

03:27.910 --> 03:32.110
I'm going to add a space between the vital and primary attributes.

03:32.110 --> 03:38.050
In fact, I'd like the primaries to be at the top, so I'm going to put those above everything else.

03:38.500 --> 03:42.090
And this will be the strength attribute.

03:42.100 --> 03:44.620
So there's that step.

03:44.740 --> 03:50.680
So there are a few things that we need to remember when we make these new attributes.

03:50.920 --> 04:00.190
Now what I can do is copy these three lines and paste them, and I can highlight these and control H

04:00.190 --> 04:05.030
to replace strength with my next attribute name.

04:05.030 --> 04:06.680
So I'm going to find strength.

04:07.170 --> 04:09.300
And I see that it's used in the en rep.

04:09.330 --> 04:15.900
The rep notify it's used for the name of the attribute and it's used in attribute accessors here.

04:16.080 --> 04:20.460
Now, my next primary attribute is going to be intelligence.

04:21.370 --> 04:23.110
So I'm going to hit replace all.

04:23.110 --> 04:32.740
And I also need my rep notify so I can come down to my rep, notifies, copy the one for strength,

04:32.740 --> 04:35.650
and I'm going to highlight the line.

04:35.680 --> 04:37.330
See that I have two strengths.

04:37.330 --> 04:44.500
I'm going to click Replace all and don't even have to type anything else up there and back here in the

04:44.500 --> 04:51.810
CPP file I'm going to copy do rep lifetime and highlight this line Ctrl H.

04:53.690 --> 04:59.810
Replacing strength with intelligence, and then it's going to try to do it to my on rep strength.

04:59.810 --> 05:00.830
That's not what I want.

05:00.860 --> 05:04.820
I want to implement on rep intelligence.

05:05.470 --> 05:13.090
Copy the gameplay attribute and then highlight this line and replace strength with intelligence.

05:13.120 --> 05:14.020
There we go.

05:14.680 --> 05:17.620
Okay, so I have two more that I'd like to make.

05:18.010 --> 05:21.340
So I'm going to copy these lines and make my third one.

05:21.340 --> 05:27.030
Now my third one, my third primary attribute is going to be resilience.

05:27.040 --> 05:30.280
So again, I'm going to replace strength with resilience.

05:31.810 --> 05:36.700
And in fact, I copied intelligence, so I need to replace intelligence actually.

05:37.450 --> 05:39.130
So I have it three times here.

05:39.130 --> 05:43.720
I'm going to replace all and we can make the rep notify.

05:44.370 --> 05:45.750
For resilience.

05:47.220 --> 05:51.600
So I'm going to highlight this replace intelligence with resilience.

05:52.320 --> 05:54.300
I'm going to generate the definition.

05:54.980 --> 05:58.310
Get my boilerplate macro.

05:59.530 --> 06:04.900
And I'm just going to manually replace intelligence with resilience here.

06:06.320 --> 06:09.210
And then finally back up to Git.

06:09.230 --> 06:10.950
Lifetime replicated props.

06:10.970 --> 06:15.940
I'm going to add one for resilience and one more.

06:15.950 --> 06:21.080
I'm going to have one more primary attribute, and I'm going to call this fourth one vigor.

06:21.110 --> 06:27.740
So I'm going to do the same steps again, and this time I'm going to replace resilience.

06:28.900 --> 06:30.010
With vigor.

06:33.630 --> 06:36.510
And we need the rep notify.

06:41.140 --> 06:42.220
There we go.

06:42.730 --> 06:45.010
We need the definition.

06:45.700 --> 06:49.810
Looks like it created an inline function definition.

06:49.810 --> 06:51.280
That's not what I wanted.

06:51.580 --> 06:54.160
I think I hit generate inline definition.

06:54.610 --> 06:55.660
No, it didn't.

06:55.660 --> 06:57.160
It just gave me one.

06:57.160 --> 07:03.970
So I'm going to cut that and just paste it in my CPP file.

07:07.220 --> 07:14.120
Get my gameplay attribute rep Notify and replace resilience with vigor.

07:16.950 --> 07:24.120
And we'll add it to get lifetime replicated props replacing resilience with vigor.

07:24.150 --> 07:31.800
Okay, so we have four new attributes and I'm seeing that on Rep vigor is not implemented.

07:31.800 --> 07:34.170
So that means I have a typo down here.

07:34.200 --> 07:36.150
No, no typo.

07:36.180 --> 07:37.770
It is implemented.

07:38.690 --> 07:42.350
And I'm just going to compile just to force writer to catch up.

07:42.350 --> 07:45.920
Yes, there should be no squiggles there, so we're good.

07:46.250 --> 07:48.410
Okay, so we have four new attributes.

07:48.440 --> 07:53.630
I'd like to initialize these attributes with a data table just to show that way of doing it.

07:53.630 --> 08:00.530
And to do that, we have to expose our ability system component to blueprint so that we can set a specific

08:00.560 --> 08:04.670
asset, a data table on that component.

08:04.940 --> 08:09.800
So I'm going to open my player folder in my public.

08:10.620 --> 08:18.540
Folder here and open or a player state where my ability system component variable is and I'm going to

08:18.540 --> 08:25.410
add visible anywhere to the view property and then I'll go ahead and compile and launch the editor so

08:25.410 --> 08:29.430
that we can see the details panel in the ability system component.

08:29.430 --> 08:36.360
So you might have tried to look at the ability system component in the player state blueprint or perhaps

08:36.360 --> 08:41.190
in the enemy blueprints and seeing that the details panel is empty.

08:41.190 --> 08:46.380
And that's because we didn't expose our ability system component to the blueprint.

08:46.380 --> 08:53.250
But now that we have, we can go into our player folder, into Aura Player State, open the full Blueprint

08:53.250 --> 08:56.070
editor and choose ability system component.

08:56.070 --> 08:59.940
And now we can see the details panel and all of the properties.

09:00.620 --> 09:09.710
Now, if we want to use a data table to initialize some attributes, we have to add an element to this

09:09.710 --> 09:13.590
array under attribute test called default starting data.

09:13.610 --> 09:21.230
If we click plus, we now have this index and you can see that it has an attributes property with a

09:21.230 --> 09:29.180
dropdown where you can choose an attribute set and a default starting table where you can choose a data

09:29.180 --> 09:29.510
table.

09:29.510 --> 09:31.880
Now you can't just choose any data table.

09:31.880 --> 09:34.490
It has to have the correct row structure.

09:34.490 --> 09:39.260
So we're going to make a data table that has that correct row structure right now.

09:39.910 --> 09:44.050
I'm going to go ahead and create a folder for this.

09:44.080 --> 09:45.580
Let's go to blueprints.

09:45.580 --> 09:47.740
And where can we put this?

09:47.770 --> 09:53.710
We can go to Ability system, right click new folder and make data.

09:53.710 --> 09:58.330
And here in data we'll make a new data table by going to miscellaneous.

09:58.360 --> 10:02.980
Selecting data table And which row structure do we want?

10:03.010 --> 10:06.220
Well, it's going to be attribute metadata.

10:06.250 --> 10:08.260
That's the structure that it has to be.

10:08.260 --> 10:16.690
Now we can click okay and we can call this DBT underscore initial primary values.

10:17.450 --> 10:21.500
And we can open it up and we can start adding some rows to this.

10:21.500 --> 10:28.970
Now, if I click plus Add, you'll see that we have new row with base value, minimum value, maximum

10:28.970 --> 10:36.200
value derived attribute info and can stack which is a boolean.

10:36.530 --> 10:38.690
So what do we fill this in with?

10:38.690 --> 10:45.080
Well, we can change the row name and if we change the row name we have to specify the attribute.

10:45.080 --> 10:54.410
And the way that we have to do so is first by specifying the attribute set name, followed by a dot,

10:54.410 --> 10:59.690
followed by the attribute so we can say ora attribute.

11:01.250 --> 11:07.520
Set dot strength, for example, and we can specify a base value.

11:07.520 --> 11:10.670
So I'm going to say ten for the strength.

11:11.000 --> 11:18.380
Save and go back to our player state and set the properties on this index for default.

11:18.380 --> 11:20.090
Starting data for attributes.

11:20.090 --> 11:24.500
I'm going to choose aura, attribute set and for default starting table.

11:24.500 --> 11:31.490
I'm going to choose initial primary values, compile, save and let's press play.

11:31.520 --> 11:33.650
Let's do our show debug.

11:33.650 --> 11:35.000
And now look at this.

11:35.000 --> 11:41.510
We have lots of other attributes and strength is set to ten and it's showing our attributes more than

11:41.510 --> 11:42.380
once.

11:44.860 --> 11:46.060
But that's okay.

11:46.090 --> 11:53.200
The point is that strength is set to ten and we can go in here and add a new row for the other attributes

11:53.200 --> 11:53.590
as well.

11:53.590 --> 11:58.990
We can say aura, attribute set dot intelligence.

12:00.550 --> 12:04.660
We can set intelligence to a base value of 17.

12:04.690 --> 12:09.910
Our character is a sorceress, after all, and we can click add.

12:09.910 --> 12:13.780
We can do Aura attribute set dot.

12:13.780 --> 12:15.090
I'm going to copy that.

12:15.100 --> 12:17.650
And this one will be resilience.

12:19.510 --> 12:21.130
This has to be spelled correctly.

12:21.130 --> 12:25.890
Obviously, we'll set this to 11 and we'll have a new one.

12:25.900 --> 12:31.030
We'll name this aura attribute set dot vigor and this will be nine.

12:31.630 --> 12:40.120
Save that press play show debug and we see that our strength, intelligence, resilience and vigor now

12:40.120 --> 12:44.290
have default values and that's great.

12:44.290 --> 12:50.350
So this is one way to initialize your attribute values and you'll see that we have min value and max

12:50.350 --> 12:53.100
value as well as some other stuff here.

12:53.110 --> 12:59.020
Derived attribute info is not something that's exposed in this struct.

12:59.020 --> 13:01.210
And then of course we have can stack.

13:01.220 --> 13:03.380
Now what do these other things do?

13:03.410 --> 13:10.280
Well, I'm going to go ahead and save all and close and open up the attribute set class.

13:11.270 --> 13:18.680
So right click on you attribute set, I'm going to go to declaration or usages and I'm going to search

13:18.680 --> 13:21.800
for attribute meta data.

13:21.890 --> 13:23.750
And here's the struct.

13:23.900 --> 13:28.490
It says Data table that allows us to define metadata about attributes.

13:28.490 --> 13:31.130
Still a work in progress.

13:31.610 --> 13:37.700
Now I'm not sure how long it's going to be a work in progress, but really the only thing this is useful

13:37.700 --> 13:42.650
for is setting the initial value for our attributes.

13:42.680 --> 13:48.620
It's not going to implement any sort of functionality for a minimum or a maximum.

13:48.890 --> 13:51.500
All it does is initialize the values.

13:51.500 --> 13:56.630
And for that reason, I'm not the biggest fan of using this method and it's not the method we're going

13:56.630 --> 13:59.450
to end up using for our primary attributes.

13:59.450 --> 14:06.230
I just wanted to show it to you because for some cases it is pretty handy.

14:06.260 --> 14:12.450
You can just fill out that data table and the ability system component is just going to fill in those

14:12.450 --> 14:15.810
values initially for you and that's great.

14:16.110 --> 14:23.790
But the preferred method that I like to use and that most people I've seen like to use is by applying

14:23.790 --> 14:29.820
a gameplay effect as soon as the game starts, for example, and that gameplay effect will set these

14:29.820 --> 14:35.370
and all of our other attributes and that's what we're going to end up using.

14:35.370 --> 14:40.110
But now you know this method and hey, the more you know, the better.

14:40.410 --> 14:43.860
So great job and I'll see you in the next video.
