WEBVTT

00:07.510 --> 00:15.730
Okay, so we're ready to actually add our ability system component and attribute set to our corresponding

00:15.730 --> 00:17.350
classes that need them.

00:17.740 --> 00:24.820
Now the first thing I'm going to do is open up my Aura character base class here, and I'd like a couple

00:24.820 --> 00:30.700
of pointers here to store the ability system component and the attribute set.

00:30.730 --> 00:34.870
That way, those pointers will be inherited by all characters.

00:34.870 --> 00:40.450
Whether those characters are going to construct these in the character class or not.

00:40.480 --> 00:46.300
Now, we've already decided that we'll be constructing and owning the ability, system component and

00:46.300 --> 00:48.730
attribute set on the enemy class.

00:48.730 --> 00:53.450
But for the player controlled character, those will be owned by the player state.

00:53.470 --> 01:00.610
So in this video we're going to take care of both of those cases, but either way or a character base

01:00.610 --> 01:06.130
is going to have pointers to the ability system component and the attribute set.

01:06.160 --> 01:08.840
We'll keep those right here in the protected section.

01:08.840 --> 01:12.890
And if we have to move them into public later for any reason we can.

01:13.010 --> 01:22.220
Now these will be object pointers, so we'll make a T object pointer of type U ability system component,

01:23.420 --> 01:32.450
not the aura version, just the engine class, and we'll call this ability system component and we'll

01:32.450 --> 01:38.270
go ahead and make this a U property and we'll also have a pointer to the attribute set.

01:38.270 --> 01:49.430
So we'll have a T object pointer for a U attribute set called attribute set, and this will also get

01:49.430 --> 01:50.630
a U property.

01:50.660 --> 01:58.760
Now we have two pointers and we want to construct these but not in or a character base because as we

01:58.760 --> 02:04.250
just said, we want the player controlled character to construct them in the player state.

02:04.250 --> 02:09.170
But for Aura Enemy, we can construct these in the enemy's constructor.

02:09.170 --> 02:13.760
So let's go into the private character folder and open Aura Enemy.

02:13.850 --> 02:18.170
And right here in the constructor we'll go ahead and construct these.

02:18.170 --> 02:22.010
We'll say ability system component equals.

02:22.010 --> 02:23.150
And this is a component.

02:23.150 --> 02:29.990
So the way to create a component in the constructor is going to be create default Subobject.

02:29.990 --> 02:36.050
And for the type, I'd like to make sure our enemy gets a U aura ability system component.

02:36.050 --> 02:43.280
So I'm going to say you aura ability system component and for the native name we'll call it ability

02:43.310 --> 02:50.780
system component so we can create an object of type aura, ability, system component and store it in

02:50.780 --> 02:54.590
our member variable which has the type ability system component.

02:54.620 --> 03:00.800
Now I see some red squiggles, which means I might have a typo somewhere because this should be legal.

03:00.800 --> 03:06.650
So I'm going to go back to our character base and sure enough, I do have a typo.

03:06.680 --> 03:12.860
I spelled component wrong, so that should fix it and that fixes the squiggles.

03:12.860 --> 03:13.370
All right.

03:13.370 --> 03:19.580
And before we can compile, these are, of course, incomplete types here, which we could forward declare

03:19.610 --> 03:20.840
right up here at the top.

03:20.840 --> 03:31.040
So we'll say class ability system component, and then we'll forward declare the attribute set as well.

03:32.790 --> 03:35.370
And that gives us a successful compile.

03:35.520 --> 03:40.530
Okay, so back in Ora Enemy, we've constructed our ability system component.

03:40.560 --> 03:44.520
We want to make sure that that ability system component is replicated.

03:44.520 --> 03:51.870
So I'm going to say ability system component set is replicated and we'll pass in True.

03:52.170 --> 03:57.630
Now there's another thing we need to do related to replication, but we're not going to do it in this

03:57.630 --> 03:58.110
video.

03:58.140 --> 04:03.720
We're going to learn about what that thing is that we need to do shortly and then we'll do it.

04:03.720 --> 04:06.450
But we're also going to construct our attribute set.

04:06.480 --> 04:08.310
We're going to say attribute set.

04:09.740 --> 04:10.310
Equals.

04:10.310 --> 04:12.290
We'll use create default subobject.

04:12.290 --> 04:15.770
This will be a you or a attribute set.

04:15.980 --> 04:21.800
So we got that base class and the native name will be attribute set.

04:22.310 --> 04:28.130
And we've now constructed our ability system component and our attribute set for the enemy.

04:28.130 --> 04:31.070
And that of course sets these pointers.

04:31.070 --> 04:34.370
So they're now populated by valid data.

04:34.370 --> 04:42.740
So ability system component and attribute set in or a character base should be valid in the enemy class.

04:42.740 --> 04:49.640
But for a character which is not an enemy, these two pointers are uninitialized.

04:49.700 --> 04:55.070
Now we need to construct these, but we don't want to do it in or a character.

04:55.070 --> 04:56.720
We want to do it in the player state.

04:56.720 --> 05:03.740
So I'm going to go ahead and open or a player state that's going to be in the player folder or a player

05:03.740 --> 05:04.960
state dot H.

05:05.120 --> 05:09.840
And I'd like to have two pointers just like we have in our character base.

05:09.840 --> 05:13.650
We want ability, system component and attribute set.

05:13.650 --> 05:20.100
So I'm just going to copy these from character base and put them here in Aura Player State.

05:20.100 --> 05:26.790
I'm going to give this a protected section and simply paste in these variables and I'd like to construct

05:26.790 --> 05:33.330
them in the Aura Player State constructor, and we'll do so the same way we did in Aura Enemy, so we

05:33.330 --> 05:39.060
can copy these lines where we're constructing these two and we can paste them in Aura Player State.

05:39.060 --> 05:46.050
So I'll open the CPP file and just above setting our net update frequency, we'll go ahead and paste

05:46.050 --> 05:51.210
these and writers telling me I need to include these header files.

05:51.210 --> 05:56.790
I can use alt enter to automatically do that for both of them.

05:56.790 --> 06:00.960
Alt enter will include those header files.

06:01.410 --> 06:08.160
So now the player state has these pointers and is setting them but still on aura character.

06:08.160 --> 06:10.830
These pointers will be null, right?

06:10.890 --> 06:16.680
Because Aura player State has its own and the base character class has its own pointers for these.

06:16.860 --> 06:22.410
So we're going to want to make sure that the aura, character, ability, system component and attribute

06:22.410 --> 06:25.950
set pointers are set and we will make sure that we do that.

06:25.950 --> 06:29.940
We'll keep in mind that that's something we still need to do.

06:30.000 --> 06:30.510
Okay.

06:30.510 --> 06:38.850
But we do know that the ability system component is constructed on both the enemy for aura enemy and

06:38.850 --> 06:41.820
the player state for aura player State.

06:41.850 --> 06:46.110
Now, there's still some setup that needs to be done and we're going to get to those things shortly.

06:46.110 --> 06:52.080
But before we do, we're going to do one last thing before wrapping this up, and that is to implement

06:52.080 --> 06:56.160
a specific interface that exists for the ability system.

06:56.160 --> 07:02.670
We're going to first implement that interface on Aura character base right here, just after a character

07:02.670 --> 07:11.840
we're going to inherit publicly, we're going to say public I ability system interface.

07:12.590 --> 07:14.330
And Ryder says, What's that?

07:14.330 --> 07:21.830
Well, Alt Enter takes me to the build file and tells me I should put gameplay abilities here and public

07:21.830 --> 07:29.180
dependency module names as we're attempting to access this from within our aura character base.

07:29.210 --> 07:34.760
Now, if we move this into the public array, we don't need this in the private, we don't need it in

07:34.760 --> 07:35.480
both places.

07:35.480 --> 07:39.830
So I'm going to go ahead and remove it from private dependency module names.

07:39.830 --> 07:41.380
We'll just keep it in the public.

07:41.390 --> 07:47.540
Now, here in our character base, writer automatically included ability system interface.

07:47.540 --> 07:49.070
Now what is this interface?

07:49.070 --> 07:54.080
Well, if I right click on it in Visual Studio, I could just peek definition.

07:54.080 --> 08:01.790
But here in writer I'm going to select go to declaration or usages to go to its header file.

08:01.970 --> 08:08.720
And we see here that it's just an interface that contains this pure virtual function get ability system

08:08.720 --> 08:09.740
component.

08:09.920 --> 08:15.930
This interface is really useful because it allows us to simply check any actor to see if it has this

08:15.930 --> 08:20.730
interface and then we can easily get its ability system component from it.

08:20.760 --> 08:25.890
Now because it's a pure virtual function, it's mandatory that we override this.

08:25.890 --> 08:32.040
So I'm going to go ahead and highlight this line so that we can override it in aura character base as

08:32.040 --> 08:33.630
we now have to.

08:33.660 --> 08:37.110
So here in the public section, I'm going to override it.

08:37.110 --> 08:42.000
We'll say const override and now we can generate a definition for it.

08:42.000 --> 08:45.150
And all I want to do in here is return that pointer.

08:45.150 --> 08:49.950
So we're going to say return ability system component and that's it.

08:49.980 --> 08:56.940
Now something I like to do when I create a getter for the ability system component is I also like to

08:56.940 --> 08:58.680
create a getter for the attribute set.

08:58.710 --> 09:00.420
It's just convenient.

09:00.420 --> 09:06.510
So along with this, I'm going to create a getter for the attribute set.

09:06.510 --> 09:16.440
So I'm going to say you attribute, set, get, attribute set and this one can also be const and I can

09:16.440 --> 09:18.960
just return attribute set here.

09:18.960 --> 09:22.350
Nothing really fancy needs to be done.

09:22.500 --> 09:24.210
I'm just going to keep it there.

09:24.240 --> 09:31.590
So our ability system interface is now implemented in the character base class and all it does is return

09:31.590 --> 09:32.430
those pointers.

09:32.430 --> 09:37.860
Now remember, if we're on a character and we call this, we could get a null pointer because we haven't

09:37.860 --> 09:40.350
ever set those pointers for a character.

09:40.350 --> 09:44.100
We only constructed it for Aura Enemy right now.

09:44.100 --> 09:50.910
I also like to implement this on the player state because I have the actual attribute set an ability

09:50.910 --> 09:52.890
system component on the player state.

09:52.890 --> 09:55.650
So we're going to implement that on the player state as well.

09:55.650 --> 10:03.090
We'll go to Aura Player State and we'll inherit from I ability system interface that's going to pop

10:03.090 --> 10:04.260
up that header there.

10:04.260 --> 10:07.980
And we now have to override that function.

10:07.980 --> 10:14.760
I'm just going to steal the declaration for both of these getters from Aura character base and I'll

10:14.760 --> 10:21.990
paste them here in the public section in our player state and go ahead and implement get ability system

10:21.990 --> 10:23.430
component here.

10:27.080 --> 10:32.360
And just return the pointer return ability system component.

10:32.360 --> 10:36.350
So at least from the player state for Aura, we can always get it.

10:36.350 --> 10:42.950
So this is just one of those convenient things that we set up for characters or other classes that have

10:42.950 --> 10:45.260
ability system components and attribute sets.

10:45.260 --> 10:48.290
We generally implement the ability system interface.

10:48.290 --> 10:52.700
That's just one of those boilerplate things that helps everything in the system, interact with each

10:52.700 --> 10:55.310
other in a nice, convenient manner.

10:55.970 --> 11:02.870
So now that we have the ability system component and attribute set pointers both on aura player State

11:02.870 --> 11:09.830
and on the Aura character base, and we're actually constructing these objects.

11:09.830 --> 11:15.650
We're doing it in Aura Enemy in the constructor and we're doing it in Aura Player State for the player

11:15.650 --> 11:16.790
controlled character.

11:16.790 --> 11:22.130
We're now ready to make that connection for the Aura character because the Aura character has these

11:22.130 --> 11:23.600
pointers and they're null.

11:23.810 --> 11:28.140
The Aura player state has non null pointers since we constructed them.

11:28.140 --> 11:35.220
Now attempting to compile, I see that aura player State dot line 20 has an error because we're not

11:35.220 --> 11:36.600
forward declaring here.

11:36.600 --> 11:40.140
That is something we're going to want to do here as well.

11:40.200 --> 11:44.400
I'm going to copy those lines where we're forward declaring in the base character class.

11:44.400 --> 11:50.580
We're going to paste those in there and let's just make sure we can compile before we continue and we

11:50.580 --> 11:51.900
have a successful compile.

11:51.930 --> 11:52.800
Perfect.

11:53.010 --> 11:53.700
Okay.

11:53.700 --> 12:02.070
So in the next video, we're going to make sure that we tell the ability system component who its owner

12:02.070 --> 12:08.790
is, and we're also going to make sure that our aura, character ability, system component and attribute

12:08.790 --> 12:12.540
set pointers point to valid data and we'll do that next.

12:12.570 --> 12:13.500
I'll see you soon.
