WEBVTT

00:07.120 --> 00:08.230
Welcome back.

00:08.260 --> 00:12.350
So here's what our gameplay ability for hit React looks like.

00:12.370 --> 00:14.110
We apply a gameplay effect.

00:14.140 --> 00:16.450
We store the handle for that effect.

00:16.480 --> 00:19.370
We get the avatar actor from actor info.

00:19.390 --> 00:27.250
Cast it to the combat interface and use get hit react montage The blueprint native event that returns

00:27.250 --> 00:30.610
that montage and we play montage and wait.

00:30.640 --> 00:37.810
Now we have set that variable for our goblin spear and goblin slingshot, but we're never actually activating

00:37.810 --> 00:38.680
this ability.

00:38.680 --> 00:43.850
So we want to do that when our enemies get damaged but are not dead.

00:43.870 --> 00:46.150
So let's go into our attributes set.

00:46.910 --> 00:53.780
And the reason is because here in aura attribute set, we know when the affected attribute is the incoming

00:53.780 --> 00:55.010
damage attribute.

00:55.010 --> 01:01.520
In fact, we know if the damage was fatal because we know that new health will now be equal to zero.

01:01.550 --> 01:09.170
If that's the case Now, if the damage was not fatal, then we should tell the enemy to activate its

01:09.170 --> 01:10.910
hit React ability.

01:10.910 --> 01:13.670
That means our enemy should have that ability.

01:13.670 --> 01:15.950
So we need to handle a few things here.

01:15.950 --> 01:22.370
We need to make sure that the enemy has the hit react ability and then we can try to activate that ability

01:22.400 --> 01:24.440
from here in the attribute set.

01:24.500 --> 01:27.740
So how do we make sure the enemy gets that ability?

01:28.040 --> 01:33.350
Well, we do have a data asset for things that all enemies should share.

01:33.440 --> 01:38.600
We know that that's an ability system data and it's called character class info.

01:39.560 --> 01:48.000
Now all enemies may want to share gameplay abilities so we can have a array of gameplay ability classes

01:48.000 --> 01:49.470
that we'd like to apply.

01:49.470 --> 01:55.980
So in this video we're going to add that to the character class info so that we can add that gameplay

01:55.980 --> 02:00.270
ability and then all enemies can have that gameplay ability.

02:00.270 --> 02:04.650
In fact, they can have all of the abilities in the array that we create here.

02:04.680 --> 02:06.210
So let's do this.

02:06.670 --> 02:08.470
So we'll make a T array.

02:10.750 --> 02:18.280
And the type for the array is going to be a subclass of and the type for the subclass of will be you

02:18.280 --> 02:19.600
Game playability.

02:20.920 --> 02:29.230
We can call this abilities and this will be a edit defaults only property and we can put this in common

02:29.230 --> 02:36.310
class defaults as this will be common to all classes so we can really just call this common abilities,

02:36.610 --> 02:38.110
but it doesn't really matter.

02:38.110 --> 02:41.680
We have an abilities array and we're going to want to set that.

02:41.680 --> 02:47.680
Now, once we've set that in the data asset, then we can make sure that all enemies have these abilities

02:47.680 --> 02:48.760
given to them.

02:49.740 --> 02:52.380
Now, how are we giving our abilities to Aura?

02:52.830 --> 02:58.520
Well, we can remind ourselves by going to character and or a character base.

02:58.530 --> 03:01.800
And we have an Add character abilities function here.

03:02.190 --> 03:06.420
We can check out its implementation on Aura character base.

03:06.450 --> 03:13.230
We see that we're getting our aura ability system component and calling add character abilities here

03:13.320 --> 03:19.930
and the aura ability system component is just taking in a array of start up abilities.

03:19.950 --> 03:25.800
We can check out that definition and we see that it just loops through the array.

03:26.700 --> 03:34.050
It creates an ability spec makes that ability have level one to start and it checks that abilities,

03:34.050 --> 03:41.310
start up input tag and adds that to the abilities dynamic ability tags before calling give ability.

03:41.340 --> 03:45.660
Now this is all very much specific to the player controlled character.

03:45.660 --> 03:49.390
Enemies don't need to care about their input tag.

03:49.410 --> 03:53.740
This is only for player controlled characters that are applying input.

03:53.760 --> 03:59.850
All we really care about is the ability system component calling, give ability, but the abilities

03:59.850 --> 04:03.660
are going to be on that data asset which exists on the game mode.

04:03.660 --> 04:12.270
And remember, we're giving our start up attribute effects using our Ability system Blueprint library,

04:12.270 --> 04:15.450
which we called or ability system library.

04:15.450 --> 04:18.860
We have the static function initialized default attributes.

04:18.870 --> 04:23.370
Well, we could do this for our default gameplay abilities as well.

04:23.550 --> 04:25.890
And this can be pretty simple.

04:25.890 --> 04:28.930
It doesn't even need to know the level or the character class.

04:28.960 --> 04:34.960
It'll just need a world context object and the ability system component and it can get that character

04:34.960 --> 04:37.270
class info from the game mode.

04:37.630 --> 04:42.300
So we'll just make a static function to initialize enemy gameplay abilities.

04:42.310 --> 04:51.310
It'll be static void and we'll call this give startup abilities and this will take a const object called

04:51.310 --> 05:00.520
world context object and it'll take a you ability system component called ASC and this can be blueprint

05:00.520 --> 05:08.110
callable and we'll put it in the same category character class defaults as our initialized default attributes

05:08.110 --> 05:12.430
and we'll go ahead and generate the function definition for this.

05:12.580 --> 05:14.550
And this will be pretty simple.

05:14.560 --> 05:20.290
We're going to get the aura game mode like we're doing initialize default attributes passing in that

05:20.290 --> 05:25.330
world context object and we'll return if that game mode is null.

05:25.330 --> 05:31.390
And once we have that, we can get that character class info from it and from the character class info,

05:31.420 --> 05:37.690
we can get the array of abilities, we can loop through it and have our ability system component, give

05:37.690 --> 05:40.060
the abilities with give ability.

05:40.060 --> 05:44.890
So let's take the first two lines from the function above and paste them here.

05:44.890 --> 05:46.900
So we're getting our aura game mode.

05:47.230 --> 05:51.790
After that, let's get the character class info, that data asset.

05:51.820 --> 05:53.140
We'll get that here.

05:54.770 --> 06:01.760
After we have that character class info, we can get that array of abilities from character class info

06:01.760 --> 06:08.080
so we can say character class info and we can get common abilities.

06:08.090 --> 06:11.660
We can loop through these common abilities with a for loop.

06:11.660 --> 06:19.430
We can say for auto ability, class in character, class info, common abilities.

06:19.430 --> 06:22.940
And we see that this is a subclass of gameplay ability.

06:22.940 --> 06:28.550
I can go ahead and change that to subclass of you gameplay ability if I like.

06:29.180 --> 06:36.620
And we can take the ability system component and call give ability and this requires an ability spec

06:36.620 --> 06:38.000
so we can create one of those.

06:38.000 --> 06:44.390
In fact we can just cheat and go back to aura ability system component and see what we did here.

06:44.390 --> 06:49.970
We took the ability class, we created a gameplay ability spec and made it like this.

06:50.330 --> 06:56.730
We can just copy that line and back here in our Ability system blueprint library, we can paste it here.

06:56.730 --> 07:00.480
We have an ability spec that we can pass in to give ability.

07:00.780 --> 07:08.820
So we now have this nice function give startup abilities that we can call to give abilities to our enemy

07:08.820 --> 07:11.250
and we can do that right here in enemy CP.

07:11.970 --> 07:18.270
We can do it in begin play as soon as we know that our ability system component is initialized, we

07:18.270 --> 07:22.320
can give those abilities and we do that with you.

07:22.470 --> 07:27.600
Aura, ability, system, library, give startup abilities.

07:27.630 --> 07:29.520
It needs a world context object.

07:29.520 --> 07:32.910
We'll pass in this and it needs the ability system component.

07:32.940 --> 07:35.430
We'll pass in ability system component.

07:35.430 --> 07:41.160
And now we should get those abilities provided that those abilities are in the data asset.

07:41.190 --> 07:41.640
Okay.

07:41.640 --> 07:48.000
So we'll have to remember to add our hit React ability to the common abilities array in the data asset.

07:48.030 --> 07:51.120
Once that's done, this function should give those abilities.

07:51.150 --> 07:57.900
Now for actually activating that ability, we can go back to our attribute set.

07:57.930 --> 08:05.460
So I'm going to close out of a couple of these classes until I see aura attribute set here and right

08:05.460 --> 08:06.090
here.

08:06.120 --> 08:11.610
As soon as we know that the damage was not fatal, we can activate the ability.

08:11.610 --> 08:14.700
We can say, if not be fatal.

08:17.350 --> 08:18.680
We can activate the ability.

08:18.700 --> 08:20.620
Now, how are we going to activate the ability?

08:20.620 --> 08:27.520
Especially because I'd like this aura attribute set to not depend on the enemy class.

08:27.610 --> 08:31.720
I don't want it to care what the owner of this is.

08:31.750 --> 08:34.330
We just want to activate an ability.

08:34.360 --> 08:37.810
Well, here's how we can do it in a nice generic way.

08:38.110 --> 08:41.750
We can activate abilities by ability tag.

08:41.770 --> 08:42.370
That's right.

08:42.370 --> 08:50.980
We can specify a tag or a set of tags and say, hey, activate an ability if you have an ability with

08:50.980 --> 08:52.370
a specific tag.

08:52.390 --> 08:55.480
We do that with the ability system component.

08:55.480 --> 09:00.760
So we know that we have this props data structure that has ability system components.

09:00.760 --> 09:07.810
We know that target ask is the owner of this attribute set right, not source but target the thing being

09:07.810 --> 09:17.260
affected and this ability system component can be used to activate abilities by tag using the function.

09:17.270 --> 09:20.070
Try activate abilities by tag.

09:20.090 --> 09:27.410
Now this takes a gameplay tag container and it has an optional bool Allow remote activation set to true

09:27.410 --> 09:34.580
by default, which basically means that we can call this function from a client and activate it predictively.

09:34.580 --> 09:38.600
Well, we're doing this on the server so that doesn't really matter.

09:38.600 --> 09:41.260
But we need a gameplay tag container to pass in.

09:41.270 --> 09:46.100
So let's make one for gameplay tag container.

09:46.250 --> 09:51.680
We'll call this tag container and we need to add a tag to it.

09:51.680 --> 09:56.330
So we'll say tag container dot add tag.

09:56.540 --> 09:57.800
What are we going to add?

09:57.800 --> 10:07.430
Well, we need to get aura gameplay tags using the get function and from that we need to get our effects

10:07.430 --> 10:14.450
dot hit react tag and we're going to pass that in and then we can call try activate abilities by tag

10:14.450 --> 10:16.990
passing in the tag container.

10:16.990 --> 10:23.530
So this is a nice generic way to say, hey, activate an ability if you have one that has this tag.

10:23.560 --> 10:24.940
Pretty nice, right?

10:24.940 --> 10:28.480
And we know that our enemy is going to have an ability with this tag.

10:28.480 --> 10:32.680
So why don't we go ahead and compile and launch the editor at this point?

10:33.040 --> 10:33.460
Okay.

10:33.460 --> 10:34.990
So attempting to compile.

10:34.990 --> 10:38.650
Looks like I'm getting a couple of errors, so let's address them.

10:38.650 --> 10:39.130
First.

10:39.130 --> 10:43.840
Character class info dot h u gameplay ability undeclared identifier.

10:43.840 --> 10:49.930
So I went ahead and just recklessly made a t array using a type that I didn't forward declare.

10:49.960 --> 10:55.030
Let's go ahead and forward declare that I'm used to right or doing this automatically, but sometimes

10:55.030 --> 10:55.870
it doesn't.

10:56.350 --> 11:00.430
So we'll stick that in there and let's try to compile again.

11:01.160 --> 11:02.030
And there we go.

11:02.030 --> 11:03.260
We have a successful build.

11:03.260 --> 11:05.420
So I'm going to go ahead and launch at this point.

11:05.450 --> 11:08.360
Now, there are a couple things to remember, right?

11:08.360 --> 11:12.560
The data asset needs that hit React ability added to it.

11:12.560 --> 11:14.390
So we can't forget that.

11:14.660 --> 11:22.040
So I'm going to go ahead and click open, but I do want to close some of these, such as the blueprints

11:22.040 --> 11:23.420
for our goblin.

11:23.750 --> 11:29.390
I'm going to close the hit React Slingshot, and I'm not using Firebolt anymore.

11:29.720 --> 11:32.030
I'm not using damage at the moment.

11:32.300 --> 11:32.930
Okay.

11:32.930 --> 11:39.440
Now I need that data asset, so I'm going to go to blueprints, ability system data and open character

11:39.440 --> 11:40.790
class info.

11:40.790 --> 11:47.920
And we know that our common abilities needs to have an element added to it and we need to choose gar

11:47.960 --> 11:52.550
hit react so that our enemies can have that ability granted to them.

11:52.850 --> 11:59.480
Once that's the case, then we can cause damage and our attribute set, if that damage is not fatal,

11:59.480 --> 12:01.470
is going to call.

12:01.470 --> 12:07.680
Try activate abilities by tag using a tag container that contains the hit React tag.

12:07.770 --> 12:14.760
Once that happens, it should activate its gar hit react ability provided that this ability has that

12:14.760 --> 12:16.800
tag now, does it?

12:16.800 --> 12:17.970
Well, no it doesn't.

12:18.000 --> 12:20.990
We have to make sure that this ability has that tag.

12:21.000 --> 12:28.470
Let's go to class defaults here and gar hit react now how do we make sure that this ability has that

12:28.470 --> 12:35.910
tag we add it to the ability tags tag container so we can add effects.

12:36.440 --> 12:37.430
Hit React.

12:38.130 --> 12:39.450
Now effects.

12:39.690 --> 12:41.880
Hit react may not be the most appropriate.

12:41.910 --> 12:43.310
We may want an ability.

12:43.590 --> 12:45.000
Hit react tag.

12:45.000 --> 12:46.080
But that's okay.

12:46.080 --> 12:51.810
We can reuse this tag as long as the enemy has the ability with this effects.

12:51.990 --> 12:52.970
Hit react tag.

12:52.980 --> 12:58.040
It'll activate this ability as soon as try activate abilities by tag is called.

12:58.050 --> 13:00.720
Once that happens, our ability will activate.

13:00.750 --> 13:03.510
We'll apply the gameplay effect to owner.

13:03.630 --> 13:09.390
We'll get the hit React montage or play montage in wait and we should see that montage played.

13:09.390 --> 13:11.370
Let's give that all a try.

13:11.400 --> 13:18.120
Kind of a lot of moving parts here, so let's see if we can at least see that hit React montage played.

13:20.660 --> 13:26.270
And we did little hard to see with the explosion, but it's definitely happening.

13:28.590 --> 13:29.910
Now it's blending in.

13:29.910 --> 13:33.450
So couple of things to tweak a little bit.

13:33.480 --> 13:42.720
We can go into assets, enemies, Goblin and animations slingshot, and we can open that, hit, react

13:42.720 --> 13:45.240
and adjust the blend time.

13:45.600 --> 13:48.930
I really don't want that fast of a blend time, if any.

13:48.960 --> 13:55.860
Perhaps a .05 will do for blend in and blend out.

13:55.860 --> 14:00.270
And same goes for my other enemy, Goblin Spear.

14:00.840 --> 14:08.070
We'll lower that, blend in and blend out time just so we can see the majority of the animation.

14:09.780 --> 14:16.890
And yes, we are definitely getting a hit react, which means our GA hit React is activating.

14:16.920 --> 14:23.850
We're never actually ending the ability and that means different things depending on the class defaults.

14:23.850 --> 14:31.740
If we look at instancing policy, instance per execution means that each time this is activated, a

14:31.740 --> 14:33.330
new instance is created.

14:33.330 --> 14:34.290
But we don't need that.

14:34.290 --> 14:41.160
We can have an instance per actor and that way this will only be instanced once when we first activate

14:41.160 --> 14:45.960
it and each subsequent activation will use the same instance.

14:53.050 --> 14:58.900
Now, that's going to mean that we should make sure to end the ability and in fact, we want to still

14:58.900 --> 15:00.820
remove this gameplay effect.

15:01.000 --> 15:03.190
So let's handle those things.

15:03.190 --> 15:09.040
And I think I'd like to remove the gameplay effect and end the ability when the montage is completed.

15:09.250 --> 15:14.950
I don't want to use on blend out because that happens slightly before the montage is completed, but

15:14.950 --> 15:19.890
if the montage gets interrupted, we should also handle that situation.

15:19.900 --> 15:21.490
Same for cancelled.

15:21.490 --> 15:28.570
So what I'm going to do is remove the gameplay effect and end the ability in these cases on completed,

15:28.600 --> 15:31.060
on interrupted and on canceled.

15:31.390 --> 15:34.330
Now to remove a gameplay effect, that's pretty easy.

15:34.330 --> 15:41.290
We can right click and type remove gameplay effect from owner with handle.

15:41.440 --> 15:47.560
Notice that there are other options with asset tags and with granted tags we're going to remove by handle

15:47.560 --> 15:55.460
and we can easily do that because we've cached our gameplay effect handle called active hit React.

15:55.460 --> 15:59.540
So we're going to bring that in as the handle for stacks to remove.

15:59.540 --> 16:04.850
We can just use negative one and we can do this on completed.

16:05.030 --> 16:08.690
We can do it on interrupted and on canceled.

16:08.690 --> 16:11.600
And as soon as we do that we'll end the ability.

16:14.520 --> 16:15.960
Like so.

16:16.470 --> 16:18.590
So now we can press play.

16:18.600 --> 16:19.590
We can.

16:20.320 --> 16:27.670
Do some damage, we get the hit react and it happens multiple times only, though, if it's not already

16:27.670 --> 16:28.540
active.

16:29.690 --> 16:32.980
So we can see that we get a little bit of a delay there.

16:32.990 --> 16:38.120
And if we'd like this to happen a little sooner, we could in fact do this on blend out.

16:40.780 --> 16:42.220
If we wanted to do that.

16:43.890 --> 16:51.870
But we're not going to get it multiple times as hit react is not ended until the montage is finished.

16:52.170 --> 16:54.300
I'm going to remove this from on blend out.

16:55.080 --> 17:01.830
Okay, so now that we've got this working, we've got a pretty nice hit React ability and we also have

17:01.830 --> 17:10.460
the opportunity to respond to when we begin and end our hit React as we're responding to gameplay tags.

17:10.470 --> 17:16.250
So we can always do things in response to receiving that hit react tag.

17:16.260 --> 17:18.210
So this is looking great.

17:18.210 --> 17:24.450
And now that we have hit reacting, then it looks a little bit more interesting when we actually cause

17:24.450 --> 17:25.290
damage.

17:25.770 --> 17:26.880
Pretty cool.

17:28.350 --> 17:29.490
It's a great job.

17:29.490 --> 17:31.680
And I'll see you in the next video.
