WEBVTT

00:06.850 --> 00:07.780
Welcome back.

00:07.780 --> 00:13.090
So we've created a singleton or a gameplay tags and we have a function.

00:13.090 --> 00:16.720
It's static called initialize native gameplay tags.

00:16.720 --> 00:23.140
Now so far we're just adding a native gameplay tag for attributes secondary armor.

00:23.350 --> 00:29.410
Now we need to call this function at some point and that's why we're going to create our very own asset

00:29.440 --> 00:30.190
manager.

00:30.190 --> 00:31.810
Now, what's an asset manager?

00:31.810 --> 00:39.970
It's another singleton and it has to do with loading primary assets, and it's where we can initialize

00:39.970 --> 00:42.850
this singleton where we can call this function.

00:42.850 --> 00:51.100
Now the asset manager is a singleton in that there is only a single one in the whole project and we

00:51.130 --> 00:53.440
set that at the project level.

00:53.440 --> 00:55.060
So we're going to learn how to do that.

00:55.060 --> 00:57.760
But first we have to create the class for it.

00:57.760 --> 00:58.690
So we're going to do that.

00:58.690 --> 01:01.630
We're going to go ahead and press run now.

01:01.630 --> 01:02.920
We need to run in debug mode.

01:02.920 --> 01:04.090
At this point in time.

01:04.090 --> 01:06.040
We're just going to make a new class.

01:06.070 --> 01:08.120
Our new asset manager.

01:08.330 --> 01:15.290
So to make our asset manager, we'll go into our C plus plus classes or public folder.

01:15.290 --> 01:16.790
We'll go ahead and put it here.

01:16.910 --> 01:18.530
New C plus plus class.

01:18.530 --> 01:25.490
We're going to choose all classes and search for asset manager and we're going to choose asset manager.

01:25.520 --> 01:26.900
We'll click next.

01:26.930 --> 01:32.570
We'll go ahead and let it go into Aura Public and we'll call this Aura asset manager.

01:32.570 --> 01:35.360
Let's create the class and close the editor.

01:35.630 --> 01:38.000
And now we can start to define this.

01:38.000 --> 01:40.430
Singleton Which is going to be quite simple.

01:40.430 --> 01:44.810
As with our other singleton, we're going to have a static get function.

01:44.810 --> 01:51.440
So let's make a public section and we'll have a function that's static that returns an aura.

01:51.470 --> 01:56.150
Asset manager reference a reference to the one and only asset manager.

01:56.570 --> 02:01.190
We'll call this get and we'll go ahead and generate this definition.

02:01.190 --> 02:04.010
And what does the get function return?

02:04.010 --> 02:06.440
Well, it's going to return the engines.

02:06.470 --> 02:09.710
Asset manager, but we're going to cast it to this type.

02:09.920 --> 02:12.860
So we're going to set the asset manager.

02:12.860 --> 02:16.940
We're going to do that in one of our config files and we'll see that very shortly.

02:17.180 --> 02:26.180
But once our project has this class set to be its asset manager, then we can define the static get

02:26.180 --> 02:31.010
function to return that asset manager cast to this class.

02:31.010 --> 02:36.560
Now we get the engines asset manager from engine Asset Manager.

02:36.800 --> 02:39.080
So that's what we're going to cast now.

02:39.080 --> 02:42.770
First we're going to assert that engine is valid.

02:43.520 --> 02:44.780
It should be.

02:44.780 --> 02:50.090
If it's not, we're going to crash intentionally because then we have larger problems.

02:50.090 --> 02:57.830
Now we're going to take its asset manager and cast so cast, what are we going to cast to?

02:57.830 --> 03:00.920
We're going to cast to your aura asset manager.

03:01.100 --> 03:09.080
Now, this is going to return a pointer for us so we can have a pointer to our asset manager called

03:09.650 --> 03:13.730
our asset manager, but this function doesn't return a pointer.

03:13.730 --> 03:15.890
It returns a reference.

03:15.890 --> 03:21.050
So we're going to return the Dereferenced pointer or an asset manager.

03:21.760 --> 03:29.230
And of course we could just dereference this and return it like this if we wanted to do it that way.

03:29.500 --> 03:31.570
But I'm going to just do it this way.

03:31.750 --> 03:32.230
Okay.

03:32.230 --> 03:39.760
So that's the first thing we have to do is we need to define the get function which will return this

03:39.790 --> 03:40.930
actual type.

03:41.230 --> 03:48.010
Now, once we've done that, our asset manager needs to override a function that exists on the asset

03:48.010 --> 03:49.150
manager class.

03:49.150 --> 03:50.470
That's a protected function.

03:50.470 --> 03:56.990
So we'll make a protected section and it's a virtual void function called Start initial loading.

03:57.010 --> 04:03.790
This is called very early on and this is when we start the initial loading for our assets for the game.

04:03.790 --> 04:10.540
And this is the perfect place for us to call that initialize native tags function that we have here

04:10.540 --> 04:11.890
in our gameplay tags.

04:11.890 --> 04:13.150
It's a static function.

04:13.150 --> 04:14.710
We can call that here.

04:14.740 --> 04:16.260
That's what we're going to do.

04:16.270 --> 04:22.250
So here in start initial loading after calling super, we're going to load the native tags.

04:22.250 --> 04:26.720
So that means we need our aura gameplay tags header file included here.

04:26.720 --> 04:35.780
So let's go ahead and include aura gameplay tags, dot h and we'll use F or a gameplay tags, double

04:35.780 --> 04:39.050
colon, initialize native gameplay tags.

04:39.200 --> 04:41.060
This will call that function.

04:41.060 --> 04:42.830
And what's that going to do?

04:42.860 --> 04:45.890
Well, it's going to initialize native gameplay tags.

04:45.890 --> 04:52.310
It's going to get the gameplay tag manager and call add native gameplay tag and that's going to create

04:52.310 --> 04:53.120
our attributes.

04:53.120 --> 04:55.550
Secondary armor gameplay tag.

04:55.550 --> 05:02.930
So now the last thing to do is set this Aura asset Manager to be our project's asset manager.

05:02.990 --> 05:03.530
Right?

05:03.530 --> 05:04.940
So how do we do that?

05:05.330 --> 05:11.390
Well, first of all, I'm going to go ahead and compile just to make sure we have no compiler errors

05:11.540 --> 05:16.430
and to set the asset manager for our project, we go to our config files.

05:17.000 --> 05:23.570
So let's go into our projects config folder and the config file we're interested in is default engine

05:23.570 --> 05:24.500
dot Ini.

05:24.800 --> 05:31.220
So here we have a number of settings and the one we're interested in setting is our asset manager.

05:31.220 --> 05:32.940
We can specify that here.

05:32.960 --> 05:40.640
Now first control F to search for asset manager and make sure that you don't have it set already so

05:40.640 --> 05:42.500
we don't have asset manager set.

05:42.500 --> 05:44.120
So here's how we set it.

05:44.210 --> 05:47.870
Find the section script, engine dot engine.

05:47.870 --> 05:50.510
Here's how we actually set it.

05:50.540 --> 05:57.890
Just under whatever lines you have under this script slash engine engine, we're going to specify the

05:57.890 --> 06:07.310
asset manager by typing asset manager class name equals script, and that's forward slash script.

06:08.880 --> 06:10.110
Forward slash.

06:10.110 --> 06:18.420
And then we use our project name, that's Aura Dot, and then our asset manager class name, Aura Asset

06:18.450 --> 06:19.460
Manager.

06:19.470 --> 06:23.820
Now we don't put the U for Aura asset manager.

06:23.910 --> 06:26.040
We leave that off.

06:26.040 --> 06:28.920
So this is how we specify Aura Asset Manager.

06:28.920 --> 06:35.340
To be our project's asset manager, we go to scripts slash engine engine here in default engine Ini

06:35.640 --> 06:44.340
and we say asset manager class name equals slash script slash aura or your project name, dot aura asset

06:44.340 --> 06:46.410
manager or your asset manager name.

06:46.410 --> 06:49.050
Let's go ahead and save and close that.

06:49.690 --> 06:53.790
And now we can go ahead and compile and launch the engine.

06:53.800 --> 06:55.240
Let's go ahead and do that.

06:55.630 --> 06:57.340
I just hit the debug button.

06:58.030 --> 07:04.480
So now that we've compiled and launched the engine, let's just go to edit project settings, gameplay

07:04.480 --> 07:11.170
tags, and let's take a look at our gameplay tags attributes and here we have secondary.

07:11.170 --> 07:14.080
And if we expand that, here's armor.

07:14.080 --> 07:20.890
If we hover over it, it says attributes dot secondary armor and in parentheses native.

07:20.920 --> 07:27.550
Now if we go to our other ones like Vital Health for example, the parentheses doesn't say native,

07:27.550 --> 07:31.000
it says the dot ini file where this is defined.

07:31.000 --> 07:34.180
So we don't have this defined in C plus plus.

07:34.180 --> 07:37.150
That's what our native gameplay tags are.

07:37.150 --> 07:38.080
And that's fine.

07:38.080 --> 07:44.320
We may not care about accessing the health tag from within C plus plus if we just want to access it

07:44.320 --> 07:48.220
within blueprint and there's no need for it to be a native tag, then fine.

07:48.220 --> 07:56.240
But what about tags that we already have like our primary attributes that are not native, they're defined

07:56.240 --> 07:58.220
in our primary attributes.

07:58.220 --> 08:00.200
Data Table What about those?

08:00.200 --> 08:01.910
What if we want those to be native?

08:01.910 --> 08:03.410
Well, we can make those native.

08:03.410 --> 08:09.590
We can just remove the table from the gameplay tag table list by hitting the trash can icon.

08:09.590 --> 08:12.890
Now we don't have those primary attributes.

08:12.920 --> 08:18.380
Careful doing this if you're using those attributes in assets and blueprints, well now those will be

08:18.380 --> 08:21.350
gone and they'll have to be set all over again.

08:21.350 --> 08:28.130
But the cool thing is we can now add gameplay tags to our project natively in our aura gameplay tags.

08:28.130 --> 08:33.680
Singleton And we now have our own Aura asset manager that starts the initial loading.

08:33.680 --> 08:36.560
That's what calls initialized native gameplay tags.

08:36.560 --> 08:37.430
That's great.

08:37.460 --> 08:42.800
The last piece of the puzzle is, well, how do we use these gameplay tags in our code?

08:42.800 --> 08:43.610
Right?

08:43.730 --> 08:46.490
Well, let's just see how we can do that.

08:46.520 --> 08:51.710
Where's a good place to test out accessing our gameplay tags in code?

08:51.710 --> 08:59.540
Well, I think perhaps in our ability system components dot cpp we have ability actor info set.

08:59.570 --> 09:01.370
Let's just test it out here.

09:01.580 --> 09:08.900
I'd like to access our native gameplay tag armor and then just prove to myself that I've accessed it

09:08.900 --> 09:11.510
by, say, printing a message to the screen.

09:11.510 --> 09:14.330
That way we'll see how we can access those tags.

09:14.360 --> 09:16.370
Now for our gameplay tags.

09:16.370 --> 09:18.800
Has that static get function?

09:18.800 --> 09:24.440
It's F or a gameplay tags double colon get.

09:24.830 --> 09:30.950
Now as soon as I did that of course writer includes or a gameplay tags for me so you'll have to make

09:30.950 --> 09:32.360
sure that you do that.

09:32.360 --> 09:33.620
And what does this return.

09:33.620 --> 09:37.820
Well it returns our gameplay tags, the one and only singleton.

09:37.820 --> 09:38.390
Right.

09:38.540 --> 09:43.310
We can store that and we'll store it in a const reference.

09:44.000 --> 09:45.920
We don't want to make a copy of it.

09:45.950 --> 09:55.250
We'll call this const for gameplay tags, reference gameplay tags, and now that we have that singleton,

09:55.250 --> 10:04.730
we can access the tags, we can say gameplay tags, dot and well, too bad we don't have a variable

10:04.730 --> 10:08.180
on that singleton for our armor, right?

10:08.180 --> 10:10.940
That's what we need and that's what we're going to add to it now.

10:10.940 --> 10:17.900
So we go back to our gameplay tags and we need a public armor gameplay tag variable.

10:18.170 --> 10:20.150
So let's add that variable.

10:20.150 --> 10:25.640
It's going to be an F gameplay tag called Here's the convention we'll use.

10:25.640 --> 10:33.110
We'll say attributes underscore secondary underscore armor.

10:33.620 --> 10:38.810
So we'll just use underscores in place of the dot for the gameplay tag.

10:39.110 --> 10:47.420
Now we need to set this right and we know that we're creating the gameplay tag in the CPP file here

10:47.420 --> 10:49.610
with add native gameplay tag.

10:49.610 --> 10:55.780
How do we associate that tag with our actual gameplay tag variable?

10:55.780 --> 10:58.930
We'll add native gameplay tag returns that tag.

10:58.930 --> 11:06.010
So what we can do is just store it in our new variable attributes secondary armor.

11:06.010 --> 11:09.640
So we'll say attribute secondary armor equals.

11:09.820 --> 11:16.870
Now we get the red squiggles because this is a static function, so we have to have some object of this

11:16.870 --> 11:17.350
type.

11:17.350 --> 11:23.200
Well, we know there's only one object of this type and we need to set the gameplay tag on that object.

11:23.200 --> 11:27.430
So we say gameplay tags, dot attributes, secondary armor.

11:27.460 --> 11:31.630
See, we have access to the one and only instance of it here.

11:31.630 --> 11:33.160
So that's how we do it.

11:33.430 --> 11:39.040
So now that this is happening, we're storing attributes, secondary armor.

11:39.160 --> 11:44.200
Then in our aura ability system component, we can take our gameplay tags.

11:45.510 --> 11:48.450
And we can access attribute secondary armor.

11:48.450 --> 11:54.060
And because this is a gameplay tag and gameplay tags have the ability to be converted to strings we

11:54.060 --> 11:57.270
can call to string, we can print a message.

11:57.270 --> 12:02.760
With this, I'm going to go ahead and comment it out while I'm working and just add a debug message

12:03.030 --> 12:06.330
engine add on screen debug message.

12:06.330 --> 12:16.110
I'll use a key of negative one time to display can be 10s ten point f color can be f color orange and

12:16.110 --> 12:32.460
the message can be f string print f will have text that says tag percent s followed by an asterisk and

12:32.460 --> 12:34.140
we'll use this expression here.

12:34.140 --> 12:39.120
Gameplay tags dot attributes secondary armor dot two string.

12:39.750 --> 12:43.650
We'll put that right there and we get a semicolon at the end.

12:44.010 --> 12:51.100
So just an on screen debug message that's going to prove to us that we're actually accessing a gameplay

12:51.100 --> 12:53.290
tag that was created natively.

12:53.290 --> 12:58.120
I'm going to go ahead and remove this comment here and to make things easier to read, let's put things

12:58.120 --> 12:59.980
on their own lines here.

13:00.930 --> 13:01.470
Like.

13:01.470 --> 13:04.170
So we'll go ahead and do that.

13:04.170 --> 13:10.200
So all that's left to do is play, test the game, start the game and see if we get this orange debug

13:10.200 --> 13:17.700
message proving that we've accessed gameplay tags natively in code and we've accessed gameplay tags,

13:17.700 --> 13:20.100
dot attributes, secondary armor.

13:20.100 --> 13:23.730
Let's go ahead, we'll run in debug mode and we'll test this out.

13:24.630 --> 13:25.890
Okay, Moment of truth.

13:25.890 --> 13:29.070
Let's press play and check it out.

13:29.100 --> 13:31.950
Tag attributes Secondary armor.

13:32.010 --> 13:38.400
Now we've got it printed four different times, but that's just because we're printing this from within

13:38.400 --> 13:40.230
the ability system component.

13:40.230 --> 13:42.750
And each of these enemies has one.

13:42.930 --> 13:49.200
If we just take one of these enemies, such as this one and hit delete and remove it, now there are

13:49.200 --> 13:54.060
only three ability system components and if we press play, we only see the message three times.

13:54.060 --> 13:55.830
So don't let that trip you up.

13:55.830 --> 13:57.900
It's only being created once.

13:57.900 --> 14:03.960
But we're printing the message here in ability actor info set, which happens three times at least in

14:03.960 --> 14:05.700
a standalone game.

14:05.790 --> 14:07.110
So this is great.

14:07.110 --> 14:08.790
We now have our asset manager.

14:08.790 --> 14:16.380
It's now set in our project and we have a singleton or a gameplay tags where we can define our native

14:16.380 --> 14:17.610
gameplay tags.

14:17.610 --> 14:23.850
Now Ryder's only letting me put a single space here, so what I'd like to do is add three more spaces

14:24.090 --> 14:28.530
so there's at least four here, just so this looks nice and indented.

14:29.070 --> 14:31.470
Okay, great job.

14:31.470 --> 14:38.760
So now that we can add native gameplay tags, I'd like to add all of our attribute tags here to aura

14:38.790 --> 14:43.560
gameplay tags, and then we can access those tags and use them in C plus plus.

14:43.560 --> 14:45.960
So we'll be doing that next.

14:46.110 --> 14:47.940
Great job and I'll see you soon.
