WEBVTT

00:06.930 --> 00:08.070
Welcome back.

00:08.340 --> 00:14.940
Now, we've seen a little bit about how ability tasks work by looking at play, montage and weight.

00:15.150 --> 00:19.350
Now, there's a lot here that seems still a little bit cryptic.

00:19.470 --> 00:25.140
We know that all the parts connect together, but the way they all connect together is still a little

00:25.140 --> 00:29.250
bit hazy because we haven't really created one of these of our own yet.

00:29.580 --> 00:35.130
So don't worry, we'll get some experience creating some tasks of our own and seeing exactly how they

00:35.130 --> 00:35.620
work.

00:35.640 --> 00:43.920
I just wanted to show you that play montage and weights is defined by this ability task class.

00:44.070 --> 00:48.330
So we'll get to more of the inner workings of tasks later.

00:48.330 --> 00:56.870
But for now I'd like to learn how we can do something in response to reaching a point in our montage

00:56.880 --> 01:03.240
because we'd like to delay spawning that projectile until we've reached a certain point right about

01:03.240 --> 01:04.380
there in the montage.

01:04.410 --> 01:08.860
Now, you should be familiar with with anim notifies.

01:08.950 --> 01:16.270
They're pretty standard and you can add them to montages and animation assets by simply right clicking

01:16.270 --> 01:21.580
down here in the notify section where you have one or more notify tracks.

01:21.790 --> 01:25.090
Now, I'd like to make a notify though that's custom.

01:25.090 --> 01:27.430
That has more capabilities.

01:27.430 --> 01:30.980
I'd like to trigger something in response to reaching this notify.

01:31.000 --> 01:39.130
What I'd like to do specifically is send a gameplay event so gameplay events can be sent along with

01:39.130 --> 01:45.160
data to a given actor and a gameplay ability can listen for events.

01:45.340 --> 01:48.100
We have an ability task for that.

01:48.370 --> 01:51.460
So I'm going to go ahead and remove these print strings.

01:51.460 --> 01:58.240
I'm going to delete them all and immediately after play montage and wait, I'm going to drag off and

01:58.240 --> 02:01.510
type wait gameplay event.

02:01.780 --> 02:09.880
Now this goes under ability and we have wait gameplay event to actor and simply wait gameplay event.

02:09.910 --> 02:13.360
We're just going to choose the basic wait gameplay event.

02:13.600 --> 02:21.280
This will wait for an event to be sent to the actor that has the ability system component that's activating

02:21.280 --> 02:22.270
this ability.

02:22.420 --> 02:29.200
Now we specify when we're waiting for a gameplay event, what event we should wait for and the event

02:29.200 --> 02:32.830
is identified with a gameplay tag.

02:33.070 --> 02:41.260
So what we can do is create a gameplay tag designed to identify specific events such as, Oh, I don't

02:41.260 --> 02:43.030
know, launching a fireball.

02:43.240 --> 02:49.750
And since the gameplay tag for this event is not something we need to access from Cplusplus at the moment

02:49.780 --> 02:54.970
I can simply add that gameplay tag to my project in project settings.

02:55.360 --> 03:03.580
So in project settings going to gameplay tags, I can add a new gameplay tag and this is going to be

03:03.580 --> 03:09.460
an event gameplay tag and our gameplay events can be of different kinds.

03:09.460 --> 03:14.740
So I'd like to have a subcategory montage and I'll call this Firebolt.

03:14.740 --> 03:21.870
So if we want to spawn a Firebolt from a montage, then we'll send an event that has this gameplay tag.

03:21.880 --> 03:31.390
So hitting enter we see that we now have event montage firebolt and in our firebolt our wait gameplay

03:31.390 --> 03:36.100
event can specify that it's waiting for an event to be sent.

03:36.100 --> 03:43.570
With this event tag, we're going to set that tag to event montage firebolt and we can see it right

03:43.570 --> 03:44.200
there.

03:44.470 --> 03:50.100
So now all that we need to do is send that gameplay event and I'd like to do that in a custom anim,

03:50.110 --> 03:55.060
notify that we're going to stick right there in this montage.

03:55.210 --> 03:57.100
So let's make that notify.

03:57.130 --> 04:04.180
I'm going to make a new folder in blueprints right here called Anim Notifies.

04:05.020 --> 04:10.690
We'll go into this and we'll make a new blueprint class based on the anim notify.

04:10.720 --> 04:13.420
So we're going to do a new blueprint class.

04:13.420 --> 04:15.700
We're going to search for anim.

04:15.700 --> 04:18.910
Notify and choose anim notify.

04:19.090 --> 04:20.770
We'll go ahead and create that.

04:21.100 --> 04:26.020
And I'm just going to call this an underscore montage event.

04:26.290 --> 04:32.110
And this will be used for any montages that wish to send a gameplay event.

04:32.140 --> 04:40.570
So we'll double click to open this up and the function on this notify that we need to override is called

04:40.570 --> 04:42.220
received notify.

04:42.220 --> 04:50.200
So if we click on functions override dropdown, we can override received notify and we can decide what

04:50.200 --> 04:53.140
happens here when the notify is reached.

04:53.140 --> 05:00.520
This function will be called when we reach the notify and we have the mesh component associated with

05:00.520 --> 05:06.400
the animation montage that's executing this notify and we can always get the owner of that mesh.

05:06.480 --> 05:07.740
With get owner.

05:07.920 --> 05:10.350
So we have the owner and that's an actor.

05:10.380 --> 05:12.660
Now, how do we send a gameplay event?

05:12.690 --> 05:19.410
Well, if we right click, we can simply type send gameplay event and here's send gameplay event to

05:19.410 --> 05:19.860
actor.

05:19.860 --> 05:23.250
We can see that its target is ability system Blueprint library.

05:23.250 --> 05:27.570
So this is in that static library, which is why it's accessible here.

05:27.750 --> 05:29.460
It's very useful.

05:29.460 --> 05:36.270
And if we send gameplay event to actor before hitting the return node, then we can specify the actor.

05:36.300 --> 05:37.590
That's why I got the owner.

05:37.590 --> 05:41.820
So we can pass the owner in there and we can specify the tag.

05:41.820 --> 05:45.750
And there's also an optional structure called payload.

05:45.750 --> 05:52.260
So as we send a gameplay event to an actor, not only are we sending an identifying tag, we can also

05:52.260 --> 05:54.600
send additional data through the payload.

05:54.600 --> 06:01.860
And if we go back to the firebolt, we'll see that wait gameplay event has this payload output and it

06:01.860 --> 06:05.550
also has this event received execution wire.

06:05.670 --> 06:13.150
So as soon as the owning actor receives the event, this event received will be executed and will receive

06:13.150 --> 06:14.110
the payload.

06:14.140 --> 06:15.340
Pretty nifty.

06:15.520 --> 06:20.500
So here in our anim notify, we're going to set the event tag.

06:20.500 --> 06:22.360
Now, we don't want to hard code this.

06:22.450 --> 06:24.810
We want this to be a variable on this anim.

06:24.820 --> 06:28.570
Notify that we can set from within the montage.

06:28.720 --> 06:33.940
So we're going to add a new variable and we're going to call this event tag.

06:34.240 --> 06:36.970
We're going to change its type to gameplay tag.

06:39.390 --> 06:42.600
And we're going to check the eye icon to make it editable.

06:42.600 --> 06:46.410
And we're going to pass the event tag in right here.

06:46.440 --> 06:52.770
Now, if you're curious what this payload contains, we can drag off of it and select make gameplay

06:52.770 --> 06:53.790
event data.

06:54.490 --> 07:01.150
And if we expand it, we see that the payload is of this structure type gameplay event data, which

07:01.150 --> 07:08.800
can contain lots of information such as a tag, an instigator, a target, two optional objects that

07:08.800 --> 07:10.750
you can set to whatever you want.

07:10.780 --> 07:18.760
A context handle instigator tags, target tags, an event magnitude which you can use for whatever you

07:18.760 --> 07:26.440
want, and even target data, which is another type of structure that can contain even more information.

07:26.440 --> 07:30.370
So payload can contain potentially a lot of info in it.

07:30.400 --> 07:32.470
We're not going to use it for this, though.

07:32.500 --> 07:34.990
We're just going to send the event tag.

07:34.990 --> 07:38.890
So compiling and saving this anim notify class.

07:38.890 --> 07:42.550
We can go back to our montage and we can add a notify.

07:42.580 --> 07:48.640
So right here in the one track, I'm going to right click add, Notify, and right here under the search

07:48.640 --> 07:56.360
bar, we have our custom anim notify and montage event if I select it and then click on it here, then

07:56.360 --> 08:00.830
in the details panel because I exposed my event tag variable.

08:00.830 --> 08:08.300
It's right here and we can expand the dropdown and choose the tag we wish to associate with this cast

08:08.300 --> 08:09.800
Firebolt montage.

08:09.800 --> 08:17.600
So I'm going to choose Firebolt now when our montage reaches this point, then received notify on this

08:17.630 --> 08:20.030
anim notify class will be called.

08:20.030 --> 08:27.380
It'll get the owner of the mesh comp and it'll send the event tag via send gameplay event to actor and

08:27.380 --> 08:32.570
that will result in the gameplay event with this event tag being received.

08:32.570 --> 08:39.200
And because this node weight gameplay event means that we're waiting for a gameplay event with the firebolt

08:39.230 --> 08:43.430
tag, then this event received will be executed.

08:43.460 --> 08:51.380
Let's just print a string and we'll say Firebolt event received.

08:51.410 --> 08:55.670
We'll go ahead and make this a yellowish orange color.

08:56.200 --> 08:58.350
And let's activate our ability.

08:58.360 --> 09:00.130
So hovering over an enemy.

09:00.160 --> 09:01.180
Clicking.

09:01.180 --> 09:06.040
And there was a little bit of a delay before we saw that message.

09:06.190 --> 09:10.090
It's really fast, so it's kind of hard to see.

09:10.120 --> 09:15.120
We could slow the montage down to say, 0.1.

09:15.130 --> 09:17.530
And now if we play the montage.

09:18.700 --> 09:24.920
Then we don't get that message until we reach that point in the montage, which is greatly slowed down.

09:24.940 --> 09:26.370
Boom, right there.

09:26.380 --> 09:29.510
And of course, we're spawning the fireball immediately.

09:29.530 --> 09:37.120
That's because we're doing it in our C plus plus function for aura, projectile spell activate ability.

09:37.300 --> 09:39.790
So we're going to want to change that, of course.

09:40.030 --> 09:47.650
But we see that now we're receiving an event thanks to our custom anim notify which calls the ability

09:47.650 --> 09:51.490
system blueprint library function send gameplay event to actor.

09:51.490 --> 09:54.040
We can call this in C plus plus even.

09:54.640 --> 10:02.530
So now we know how to receive events via wait gameplay event in our gameplay ability.

10:02.710 --> 10:09.580
So now what we need to do is make sure that we're spawning our projectile only when we receive this

10:09.580 --> 10:09.970
event.

10:10.000 --> 10:14.020
We don't want to spawn it immediately because it doesn't look right.

10:15.250 --> 10:19.900
You see, we should spawn it right there when we receive that event.

10:20.260 --> 10:27.070
So I'm going to go back to my montage set the rate scale back to 100 or 1, which is 100%.

10:27.610 --> 10:34.510
And in the next video, we're going to go about only spawning the projectile when we receive the gameplay

10:34.510 --> 10:35.230
event.

10:35.620 --> 10:36.430
Excellent job.

10:36.430 --> 10:38.020
I'll see you in the next video.
