WEBVTT

00:06.900 --> 00:07.990
Welcome back.

00:08.010 --> 00:14.280
So now that we know about gameplay tags and how to add them to our project and we have a few here,

00:14.310 --> 00:20.080
let's see how we can add gameplay tags to any given ability system component.

00:20.100 --> 00:22.560
We can do this in a number of ways.

00:22.560 --> 00:25.080
One of those ways is gameplay effects.

00:25.290 --> 00:29.190
Now let's see what happens if we take one of our crystals.

00:29.190 --> 00:36.300
Here's a health crystal, I'm going to duplicate one of them and bring it over next to my player start.

00:36.960 --> 00:44.070
Okay, so we know that we can pick one up and for one second our health starts to increase.

00:44.250 --> 00:49.860
And that's thanks to our gameplay effect in that crystal, which is in Blueprints.

00:49.890 --> 00:55.560
Actor Crystal and the Health crystal uses crystal Heal.

00:55.590 --> 00:58.980
Now this is a periodic gameplay effect.

00:59.010 --> 01:08.980
Now gameplay effects can have tags and under the tag section we have a lot of different types of tags

01:08.980 --> 01:10.960
and they all do different things.

01:11.110 --> 01:19.060
This makes the gameplay effect extremely versatile, but also maybe a little bit confusing as you don't

01:19.060 --> 01:21.700
really know which tags to use and when.

01:22.030 --> 01:29.260
So we'll quickly go over all the different types of tags and then we'll add a tag to Crystal Heal and

01:29.260 --> 01:33.610
see how we can add that to Aura's ability system component.

01:33.610 --> 01:36.850
So let's go in order from top to bottom.

01:36.850 --> 01:40.450
First we have gameplay effect asset tag.

01:40.890 --> 01:45.400
And if we expand that, we have combined tags added and removed.

01:45.420 --> 01:49.200
Now, if we hover over these, we get useful comments.

01:49.200 --> 01:56.580
This one says the gameplay effects tags, tags, the gameplay effect has and does not give to the actor.

01:56.610 --> 02:03.870
Okay, so that's good to know if we put some tags here when the gameplay effect gets applied, it's

02:03.870 --> 02:09.980
not going to give those tags to the actors ability system component, it just has the tags.

02:09.990 --> 02:11.550
So why is that useful?

02:11.550 --> 02:14.970
Well, we're going to see very shortly why that is useful.

02:14.970 --> 02:15.660
Now.

02:15.660 --> 02:19.880
Why are there three types combined, added or removed?

02:19.890 --> 02:28.230
Well, hovering over combined says tags that I inherited and tags that I added minus tags that I removed.

02:28.260 --> 02:33.270
This is what we'll see in all tag containers.

02:33.270 --> 02:38.550
And that's what these are, is gameplay tag containers that exist in all the engine classes.

02:38.580 --> 02:43.360
Now, it doesn't make a whole lot of sense here in a gameplay effect because we don't typically subclass

02:43.360 --> 02:51.220
gameplay effects, so we don't create inheritance hierarchies of gameplay effects, but we do sometimes

02:51.220 --> 02:55.090
make inheritance hierarchies of other gas classes.

02:55.090 --> 02:55.930
So we'll see.

02:55.930 --> 03:03.850
This trend now added is the comment, says tags that I have in addition to my parents tags.

03:03.850 --> 03:10.300
So a class will inherit its parents tags, but it can add its own.

03:10.300 --> 03:17.260
So in other words, if we want to add a tag to this container, we would add it here now removed, says

03:17.290 --> 03:20.530
tags that should be removed if my parent had them.

03:20.530 --> 03:25.450
So again, we won't be creating a child from any gameplay effect.

03:25.450 --> 03:31.690
But if we did, if this were a child, for example, it would inherit its parents gameplay tags.

03:31.690 --> 03:37.090
And if we wanted this child to not have one of those inherited tags, we would add that to the removed

03:37.090 --> 03:38.170
section here.

03:38.170 --> 03:46.330
Now we know that adding a tag to gameplay effect asset tag doesn't give that tag to the actor that's

03:46.330 --> 03:48.310
being hit by this effect.

03:48.310 --> 03:48.880
Right?

03:48.970 --> 03:55.840
So let's continue down to the next one which is granted tags, and if we expand it, we see the same

03:55.840 --> 03:58.780
thing combined, added and removed here.

03:59.170 --> 04:05.950
Now hovering over granted, we see these tags are applied to the actor I am applied to.

04:06.220 --> 04:06.910
Okay.

04:06.910 --> 04:14.320
So that means if we put a tag in here, it will be applied, it will be given to whatever we hit with

04:14.320 --> 04:15.220
this effect.

04:15.220 --> 04:16.780
So let's see how that works.

04:16.780 --> 04:20.920
Let's add one and we add one with the added right.

04:20.920 --> 04:27.400
So we can click on the dropdown and let's just add attributes, vital health.

04:27.400 --> 04:33.940
We'll add that and you'll see that as we click on the checkbox for health, we can add the tag and it

04:33.940 --> 04:40.510
appears here now to remove it, we just hit the red X, So adding and removing is pretty simple now

04:40.510 --> 04:43.900
because tags are hierarchical, we could add part of that tag.

04:43.900 --> 04:48.160
For example, attributes vital if we wanted to do that.

04:48.160 --> 04:53.140
And that just is a showcase of how versatile tags can be.

04:53.140 --> 04:57.100
But we're going to add attributes, vital health.

04:57.100 --> 05:00.060
Let's add that now we can add multiple, right?

05:00.070 --> 05:04.150
We can expand the dropdown and check multiple checkboxes.

05:04.150 --> 05:06.550
And as we add them, we'll see them here.

05:06.730 --> 05:13.120
And of course we can hit the X here to remove them or we can expand the dropdown and just uncheck those

05:13.120 --> 05:15.400
checkboxes and that does the same thing.

05:15.400 --> 05:16.810
It also removes them.

05:17.020 --> 05:22.360
So we've added attributes vital health to the granted tags.

05:22.360 --> 05:27.220
Now as soon as I compile, watch the combined tags here, I'm going to hit compile.

05:27.340 --> 05:34.510
And now we see that all of the tags we added to the added section are now in combined tags.

05:34.510 --> 05:41.020
And if the parent class of this had some tags and it's granted tags, we'd see those here too.

05:41.020 --> 05:41.830
But it doesn't.

05:41.830 --> 05:42.580
So we don't.

05:42.580 --> 05:49.450
But because we added one to the added section, it's now in combined tags and we see that as soon as

05:49.450 --> 05:55.060
we compile, if we remove it from added and then compile again, it goes away.

05:55.060 --> 05:56.980
It's no longer in combined tags.

05:56.980 --> 06:04.210
So anyway, let's put that health tag back into the added section we can compile and let's see what

06:04.210 --> 06:04.930
happens.

06:04.930 --> 06:14.770
I'm going to press play and show debug ability system and keep your eye right up here on owned tags

06:14.770 --> 06:17.680
and let's pick up the crystal and there it is.

06:17.710 --> 06:18.760
Attributes vital health.

06:18.760 --> 06:26.230
It was only there for a second because it gets removed as soon as this gameplay effect expires.

06:26.260 --> 06:31.800
To make this a little easier to see, let's change the duration magnitude.

06:31.810 --> 06:33.340
Here's the duration magnitude.

06:33.340 --> 06:34.240
It's set to a second.

06:34.240 --> 06:35.650
Let's set it to four seconds.

06:35.650 --> 06:36.970
That's a little easier.

06:36.970 --> 06:40.270
And then we can press play, show, debug and pick up.

06:40.340 --> 06:43.460
The crystal, keeping our eye on owned tags.

06:43.760 --> 06:48.800
And there it is attributes vital health and notice in parentheses it has a one there.

06:48.800 --> 06:58.070
We can keep count of these now that's because tags can be stacked much like gameplay effects can be

06:58.070 --> 06:58.580
stacked.

06:58.580 --> 07:00.650
But there's a key difference here.

07:00.680 --> 07:08.930
Our crystal health has its stacking type set to aggregate by target with a stack limit count of one.

07:08.960 --> 07:12.890
Okay, so we can only stack one, but let's say we increase that.

07:12.890 --> 07:15.530
Let's say we want to be able to stack four at a time.

07:15.830 --> 07:20.690
You might expect that we would stack those gameplay tags that are granted.

07:20.690 --> 07:24.080
In other words, this attributes vital health tag.

07:24.080 --> 07:29.150
You would expect us to add that tag four times and we'd get four stacks.

07:29.150 --> 07:30.860
But that's not how it works.

07:30.860 --> 07:37.400
You see, if we're applying crystal health and it's stackable, in this case it is.

07:37.400 --> 07:43.680
We're only going to get that tag once because it counts as just a single application of the gameplay

07:43.680 --> 07:44.400
effect.

07:44.400 --> 07:46.920
Only it has stacks, right?

07:46.920 --> 07:54.780
And based on the stacking policy and all of these parameters, the meaning of that depends on all these

07:54.780 --> 07:55.710
settings.

07:55.710 --> 08:04.140
So if I duplicate a few of these, let's have say three of them here and press play and show debug and

08:04.140 --> 08:11.250
pick them all up, we still just have a single health tag until they're all gone and then it's gone.

08:11.580 --> 08:18.840
So with a stackable effect, we just get that tag once because it's the effect that stacks, it's the

08:18.840 --> 08:22.310
effect stack count that goes up when we get multiples.

08:22.320 --> 08:26.790
However, let's say that this is not a stackable effect.

08:26.790 --> 08:31.770
If we take our stacking type and set it to none now, it doesn't stack anymore.

08:31.770 --> 08:38.610
We just apply the effect multiple times and each time counts as a new gameplay effect.

08:38.610 --> 08:40.470
Let's see what happens now.

08:40.500 --> 08:45.750
We'll show debug and pick up all three of these, keeping our eye on the owned tags.

08:45.750 --> 08:50.670
And now we see that we have three of the attributes vital health tags.

08:50.670 --> 08:56.520
And then it went down to two and then down to one when those effects expired.

08:56.670 --> 09:02.850
So that's a key difference between stacked effects and stacked tags.

09:02.850 --> 09:11.430
If our effect doesn't stack, then we'll get multiple effects applied, each of which adds that tag

09:11.460 --> 09:13.380
to the ability system component.

09:13.380 --> 09:18.120
And when the same tag gets added twice, then the tag count goes up.

09:18.120 --> 09:25.230
But if this is a stackable effect, if we set its stacking type to anything other than none, then applying

09:25.230 --> 09:32.130
this effect multiple times means that the effect stack goes up and we're only going to apply that tag

09:32.130 --> 09:32.820
once.

09:32.850 --> 09:33.900
Makes sense.

09:34.110 --> 09:41.190
Okay, so now we know we can add a tag when a duration based effect is added.

09:41.190 --> 09:42.660
So that's nice.

09:42.840 --> 09:48.360
And there are ways to respond to when a tag gets added to an ability system component so that can be

09:48.360 --> 09:49.110
useful.

09:49.320 --> 09:55.140
What happens though, if we add a tag to say, an instant gameplay effect?

09:55.140 --> 09:58.590
We know that these potions have instant gameplay effects.

09:58.590 --> 10:06.600
Let's go back into our potion folder into G potion mana and let's go to our granted tags and let's add

10:06.600 --> 10:07.080
a tag.

10:07.080 --> 10:09.000
Let's add the mana tag to it.

10:09.030 --> 10:12.060
Let's see what happens if we pick up one of the potions.

10:12.060 --> 10:15.690
I'm going to show debug keeping my eye on the own tags.

10:15.690 --> 10:17.340
I'm going to pick up a potion.

10:17.460 --> 10:22.290
Wait a minute, there's nothing there so we don't see anything.

10:22.410 --> 10:24.390
So that tells us something, right?

10:24.390 --> 10:32.250
Granted, tags really only mean something when our effect has a duration, because when the effect is

10:32.250 --> 10:34.680
gone, the tag is removed.

10:34.680 --> 10:40.350
And if it's an instant effect, well, there's no period during which we have the tag.

10:40.350 --> 10:41.490
We don't get it.

10:41.490 --> 10:45.050
So it doesn't matter in an instant gameplay effect.

10:45.050 --> 10:47.570
So I'm just going to clear that doesn't matter.

10:47.750 --> 10:51.230
But what happens if we want to receive a tag anyway?

10:51.560 --> 10:58.520
What happens if we pick up a potion and we want to know based on some gameplay tag that we just picked

10:58.520 --> 11:04.490
up a potion and we want to show something to the screen, we want to display a message that says Picked

11:04.490 --> 11:05.750
up Health Potion.

11:05.750 --> 11:14.570
Well, that's where our gameplay effect asset tag container comes in because we have ways to know when

11:14.570 --> 11:17.000
any type of effect has been applied.

11:17.030 --> 11:20.870
The ability system component has lots of ways to know.

11:20.900 --> 11:22.970
We're going to learn about those ways to know.

11:22.970 --> 11:29.060
In fact, we're going to peek at a couple of them in the code base now and then in the videos to come.

11:29.060 --> 11:30.800
We'll make use of them.

11:30.800 --> 11:36.860
So I'm going to undo what we did by removing that tag from crystal heal.

11:36.860 --> 11:38.840
We don't want to use granted tags.

11:38.840 --> 11:40.160
So removing that tag.

11:40.570 --> 11:42.730
And closing those gameplay effects.

11:42.730 --> 11:44.410
I don't need project settings.

11:44.410 --> 11:46.120
I'm going to close that as well.

11:46.510 --> 11:48.370
Make sure everything is saved here.

11:48.370 --> 11:54.580
I'm going to close out of the editor and I'd like to take a look at the Ability system component class.

11:54.670 --> 12:00.850
Now here in Writer, I can hit shift, shift and search for ability system component.

12:00.850 --> 12:08.550
Here's the header file and it can actually be really informative to just go through this class, right?

12:08.560 --> 12:09.760
It's a big class.

12:09.760 --> 12:15.790
There are almost 2000 lines of code, but it's an informative class.

12:15.790 --> 12:18.370
It's filled with comments everywhere.

12:18.400 --> 12:23.440
This is basically your documentation for gas is the code itself.

12:23.440 --> 12:25.330
It's filled with comments.

12:25.330 --> 12:28.450
This is basically Epic's documentation for gas.

12:28.450 --> 12:36.880
And if you're not pressed for time, I recommend just sitting down and reading through ability system

12:36.880 --> 12:37.640
components.

12:37.660 --> 12:42.170
H Read all the comments, read everything because it's all going to make sense.

12:42.170 --> 12:46.820
And you'll also see the things that the ability system component has.

12:46.820 --> 12:54.260
So while you don't have to, it might sound like torture to you to read 2000 lines of code, but I do

12:54.260 --> 12:55.340
recommend it.

12:55.340 --> 12:58.700
I recommend just sitting through, even just skimming through.

12:58.730 --> 13:00.500
You don't have to look at all the code.

13:00.500 --> 13:04.460
Just look at the comments and the names of the functions and variables.

13:04.460 --> 13:05.180
That's it.

13:05.180 --> 13:10.280
Just skim through the comment, take note of what the function is called and move on.

13:10.280 --> 13:13.070
Skim through the comment and the functions without comments.

13:13.070 --> 13:14.840
Just take note that they're there.

13:14.840 --> 13:15.440
Right?

13:15.470 --> 13:21.230
This is going to let you know just what the ability system component class has in it.

13:21.230 --> 13:27.680
So that way in the future, if you want to do something, you can just think, well, I did see something

13:27.680 --> 13:29.810
back when I skimmed through it.

13:29.900 --> 13:32.750
Related to this, maybe that'll work, right?

13:32.750 --> 13:37.610
So anyways, that's just a piece of advice that I have for you.

13:37.730 --> 13:46.550
Now, after you've done that, I want you to search for your on game play effect applied.

13:46.550 --> 13:47.900
And look at this.

13:47.990 --> 13:55.370
Here's a declare multicast delegate three params called F on gameplay effect applied delegate.

13:55.370 --> 13:58.460
If we keep searching for this same thing, we'll see that.

13:58.460 --> 14:03.740
Here's a function on gameplay effect applied to target apply to self.

14:03.740 --> 14:10.910
And if we scroll just a bit past that, here we see some actual delegate variables.

14:11.180 --> 14:15.590
Now the comments are pretty useful here on gameplay effect.

14:15.590 --> 14:20.750
Applied Delegate to Self has a comment that says called on server.

14:20.750 --> 14:29.060
Whenever a G is applied to self, this includes instant and duration based games or gameplay effects

14:29.270 --> 14:31.190
now called on server.

14:31.190 --> 14:37.040
That's pretty significant and based on our replication policy, we should know whether or not gameplay

14:37.040 --> 14:38.750
effects will be replicated.

14:38.930 --> 14:41.630
In fact, let's pull up that table real quick.

14:41.630 --> 14:42.530
Here we go.

14:42.530 --> 14:47.780
It's good to go back and look at these things because this actually has more meaning for us now, doesn't

14:47.780 --> 14:48.320
it?

14:48.410 --> 14:54.140
Now that we're starting to get into gameplay effects now, we're not using full for anything.

14:54.140 --> 14:59.600
We're using mixed and minimal or uses mixed and the enemies use minimal.

14:59.600 --> 15:06.110
Now we see that in mixed gameplay effects are replicated to the owning client only gameplay cues and

15:06.110 --> 15:11.510
gameplay tags replicated to all clients and for minimal gameplay effects are not replicated.

15:11.510 --> 15:16.640
Gameplay cues and gameplay tags are okay, so that's good to know isn't it?

15:16.640 --> 15:24.500
And here we have a delegate that will be broadcast whenever any gameplay effect is applied to self.

15:24.500 --> 15:27.800
That means to this ability system component.

15:27.830 --> 15:32.180
We also have on gameplay effect applied delegate to target.

15:32.450 --> 15:39.350
So when a gameplay effect is applied to someone else, this includes instant and duration based games,

15:39.350 --> 15:43.400
and when it says duration based, it's counting both duration and infinite.

15:43.430 --> 15:47.780
Now next we have on active gameplay effect added delegate to self.

15:47.780 --> 15:53.360
Now this is gameplay effect added right not just applied but added.

15:53.360 --> 15:57.950
Whenever you see added, that means it's for duration based gameplay effects.

15:57.950 --> 16:02.120
And here it says instant gameplay effects did not trigger this.

16:02.120 --> 16:05.630
So this is only for duration or infinite.

16:05.660 --> 16:11.870
Here we have on periodic gameplay effect, execute delegate on self and it says called on server.

16:11.870 --> 16:18.830
Whenever a periodic gameplay effect executes on self, so say we have a periodic one right?

16:18.830 --> 16:21.680
Every second something is modified.

16:21.680 --> 16:27.320
Well, here's a delegate that will be broadcast on the periodic execution.

16:27.320 --> 16:32.870
And then here we have one for when a periodic GE is executing on a target.

16:32.870 --> 16:38.420
So in other words, we have a lot of different things that we can take advantage of here.

16:38.420 --> 16:39.080
Right.

16:39.140 --> 16:40.160
And.

16:40.230 --> 16:47.150
I like on gameplay effect applied because it includes instant and duration based gameplay effects.

16:47.160 --> 16:51.580
And of course we can do things when effects are removed as well.

16:51.600 --> 16:58.380
Let's search for on gameplay effect removed and we have a lot of things.

16:58.500 --> 17:00.540
Let's keep searching.

17:00.840 --> 17:06.990
Let's search for on any gameplay effect removed.

17:06.990 --> 17:12.570
And here's something that's called when any gameplay effects are removed.

17:12.690 --> 17:15.870
Now this is a function, but it returns the delegate.

17:15.900 --> 17:17.370
It returns a reference to it.

17:17.370 --> 17:23.700
So we'd have to call this function if we want to bind anything to this delegate and these delegates

17:23.700 --> 17:30.300
broadcast info right, we're going to be able to know what effect is being applied, added, removed,

17:30.300 --> 17:31.440
whatever we want.

17:31.470 --> 17:34.560
The ability system component has you covered.

17:34.590 --> 17:35.190
Okay.

17:35.190 --> 17:41.740
So in the videos to come, we're going to bind some stuff to these delegates so we can know and then

17:41.740 --> 17:45.520
we can get those delegates and perhaps see what tags they have.

17:45.520 --> 17:50.290
And that will allow us to retrieve tags for a gameplay effect.

17:50.290 --> 17:52.660
That's perhaps instant, right?

17:52.660 --> 17:58.570
And then we don't have to rely on duration based effects if we want to do something in response to a

17:58.570 --> 18:02.390
gameplay effect applied to us, like showing something in the HUD.

18:02.410 --> 18:03.700
So excellent job.

18:03.700 --> 18:07.090
I hope you at least skim through the ability system component.

18:07.120 --> 18:12.910
If you're super curious, you can go to the CPP file and see the implementation details of it as well.

18:13.060 --> 18:18.610
So do that if you're so inclined, and I'll see you in the next video.
