WEBVTT

00:00.410 --> 00:02.360
Welcome to your next quest.

00:02.630 --> 00:08.010
In this quest, you're going to play an attack montage, so you should know how to do this.

00:08.030 --> 00:11.250
You're going to do this in our new melee attack ability.

00:11.270 --> 00:19.610
So go ahead and decide how you're going to go about making a montage and we'll go ahead and just use

00:19.610 --> 00:22.250
an attack montage for the Goblin Spear.

00:22.250 --> 00:28.550
And later, we'll work on making this ability reusable among other types of melee attackers.

00:28.550 --> 00:32.960
So for now, pause the video and conquer this quest now.

00:35.830 --> 00:38.680
Okay, we're going to want to play an attack montage.

00:38.680 --> 00:43.720
So we're going to open up our brand new gameplay ability for attacks.

00:43.810 --> 00:51.840
Let's go to Ability System in our blueprints folder, open up gameplay abilities and gar melee attack.

00:51.850 --> 00:54.840
So here in Melee Attack, we're going to play a montage, right?

00:54.850 --> 01:04.870
That means we need to use a play montage node and we're going to use the play montage and wait ability

01:04.870 --> 01:05.590
task.

01:05.590 --> 01:12.130
So for this we're just going to hardcode a montage for now, but we'll make this more versatile later.

01:12.130 --> 01:14.230
We just want to get things working for now.

01:14.230 --> 01:17.680
So for the montage to play, we need a montage, right?

01:17.680 --> 01:22.120
And we only have hit React montages for the goblins.

01:22.120 --> 01:24.490
We're going to need one for an attack.

01:24.730 --> 01:33.640
So let's go to the assets folder into Enemies Goblin and animations and spear and we have our spear

01:33.670 --> 01:34.900
goblin animations.

01:34.900 --> 01:36.530
We're going to want an attack.

01:36.530 --> 01:38.630
And here we have Attack spear.

01:38.660 --> 01:41.330
This is going to be just perfect for us.

01:41.360 --> 01:44.510
Let's make a montage based on this.

01:44.510 --> 01:46.970
So I'm going to right click on Attack Spear.

01:47.000 --> 01:55.760
We're going to use Create, Create and a montage and we're going to call this Am underscore attack Goblin

01:56.150 --> 01:57.170
Spear.

01:57.590 --> 02:04.490
And just to be consistent with my hit React, there will be no underscore between Goblin and spear.

02:04.490 --> 02:06.260
So we have an attack goblin.

02:06.260 --> 02:06.800
Spear.

02:06.830 --> 02:07.640
Right.

02:07.760 --> 02:12.410
So for now, that's all I want to do is just create this attack montage.

02:12.410 --> 02:19.250
We'll go ahead and use this in Gar melee attack and play montage and wait, we're going to use Attack

02:19.250 --> 02:22.760
Goblin Spear and just play that montage.

02:22.910 --> 02:28.070
Now, as soon as this montage has completed, I'm going to end the ability.

02:28.070 --> 02:30.920
So we're going to use end ability like this.

02:31.910 --> 02:33.860
And there we have it.

02:33.890 --> 02:35.940
Our ability plays a montage.

02:35.960 --> 02:41.990
So let's see how this works by pressing play and we'll see our goblin spear run up to us.

02:41.990 --> 02:43.900
And there we go.

02:43.910 --> 02:44.980
It's attacking.

02:44.990 --> 02:49.190
Now it moves to another location and then it attacks again.

02:50.220 --> 02:52.650
So this is looking pretty good.

02:52.920 --> 02:56.070
And there's a couple of issues.

02:56.070 --> 03:02.250
For one, I saw that the goblin is attacking not quite straight on sometimes.

03:02.250 --> 03:05.240
Sometimes it attacks with its spear off to the side.

03:05.250 --> 03:11.160
So that's something we're going to want to work on, but that's something we could fix as we've fixed

03:11.160 --> 03:12.420
this kind of issue before.

03:12.420 --> 03:18.200
With Aura, you see, if Aura is launching an ability behind her, she turns around.

03:18.210 --> 03:18.690
Why?

03:18.720 --> 03:24.440
Because she has a root motion attack animation, and we're using motion warping.

03:24.450 --> 03:26.370
How are we using motion warping?

03:26.370 --> 03:32.790
Well, we can go into blueprints, into character aura and open up aura character.

03:32.790 --> 03:40.080
And we have this event update facing Target where we're getting our motion warping component on aura,

03:40.080 --> 03:45.840
which we added on the blueprint and we're using Add or update warp target from location.

03:45.840 --> 03:51.880
So we have this event, this interface event update facing Target.

03:51.910 --> 03:56.020
Now why can't we just do this for the enemy as well?

03:56.020 --> 04:00.940
Just to remind ourselves, if we go into our combat interface, here is that event.

04:00.940 --> 04:06.460
It's a blueprint, implementable event, blueprint callable, and it's called Update facing Target,

04:06.460 --> 04:10.990
which takes an F vector by const reference called Target.

04:10.990 --> 04:15.670
So there's no reason why we can't implement this on the enemy class.

04:15.670 --> 04:23.530
And in fact, we have a base enemy blueprint that we can use BP enemy base, we can implement that interface

04:23.530 --> 04:24.550
function here.

04:24.580 --> 04:27.400
It's called Update facing Target.

04:27.430 --> 04:33.490
Now there's the function call because it's blueprint callable, and then there's the event because it's

04:33.490 --> 04:35.410
blueprint implementable event.

04:35.440 --> 04:40.780
We want the event so we can decide what happens when the function gets called for the enemy.

04:40.810 --> 04:47.410
Now, the enemy doesn't have a motion warping component like BP or a character, so we're going to need

04:47.410 --> 04:49.120
to add one to enemy base.

04:49.120 --> 04:52.660
We're going to click Add and let's search for motion warping.

04:52.660 --> 04:53.620
Here it is.

04:53.620 --> 04:59.860
We can add the motion warping component, we can drag it out and we can do what we did in Aura character

04:59.890 --> 05:04.750
add or update warp target from location choosing, facing target.

05:04.750 --> 05:05.800
So let's do that.

05:05.800 --> 05:12.280
We're going to call Add or update warp target from location and we're going to choose to use the same

05:12.280 --> 05:16.090
naming convention facing target for the warp target name.

05:16.090 --> 05:20.590
And we're going to use the target as the target location and hook that up.

05:20.590 --> 05:29.620
So now if our enemy is ever playing a root motion montage that has a motion warping notify State with

05:29.620 --> 05:35.080
facing target as the warp target name, then this is going to set that warp target.

05:35.080 --> 05:42.910
So all we need to do is call update facing target and we can make our enemies rotate to face a facing

05:42.940 --> 05:43.690
target.

05:43.690 --> 05:50.530
So let's go to our attack Goblin Spear and we can simply add a notify state with that facing target

05:50.560 --> 05:52.060
warp target name.

05:52.060 --> 05:59.110
So I'm going to go down to the notifies and rename the first track to Motion warping, and I'm going

05:59.110 --> 06:03.730
to right click on that track, add, notify state and choose motion warping.

06:03.730 --> 06:09.160
And I'm going to put this pretty close to the beginning and I'm going to grab the other end, the right

06:09.160 --> 06:14.320
hand side of it, hold shift so I can preview the animation at that point.

06:14.320 --> 06:20.320
And I'd like to warp to just about right here before the enemy starts that thrust.

06:20.320 --> 06:26.050
So we'll rotate to face the target by here and then we'll thrust at that target.

06:26.050 --> 06:33.580
So with motion warping this notify state selected, we can configure it by expanding root motion modifier

06:33.580 --> 06:35.710
and changing the warp target name.

06:35.710 --> 06:41.500
Now, back in enemy base, we see that that warp target name that we should use is facing target.

06:41.500 --> 06:45.520
So we're going to call that warp target name facing target.

06:45.610 --> 06:48.520
Now we only want to warp rotation.

06:48.520 --> 06:53.080
So what we can do is we can uncheck warp translation.

06:53.080 --> 06:58.090
Now we only have warp rotation and for rotation type I want facing.

06:58.090 --> 07:01.480
So we'll rotate to face that target.

07:01.480 --> 07:04.210
So now we're all set up to use motion warping.

07:04.210 --> 07:11.350
The only thing left is to actually call this function update facing target with an appropriate target

07:11.350 --> 07:12.100
to face.

07:12.100 --> 07:14.710
So what do we want to rotate to face?

07:14.710 --> 07:22.150
Well, if we're in melee attack on this enemy, we want to rotate to face aura, the thing that this

07:22.150 --> 07:26.890
enemy is trying to attack now, it doesn't really have a reference to aura.

07:26.890 --> 07:31.750
It needs some kind of variable for a combat target.

07:31.750 --> 07:38.890
So what we're going to do is add a combat target to the enemy so that it can rotate to face that combat

07:38.890 --> 07:39.700
target.

07:39.700 --> 07:42.940
And then we need to access that combat target here.

07:42.940 --> 07:45.940
We also need to set that combat target somehow.

07:45.940 --> 07:49.360
So in the next video, we're going to add a combat target.

07:49.400 --> 07:56.290
Target variable to our enemy so that it can use that combat target to motion warp towards that target,

07:56.290 --> 08:01.720
to face that target every time the enemy attacks with a melee attack.

08:01.720 --> 08:03.190
And we'll do that next.

08:03.190 --> 08:05.290
So great job and I'll see you soon.
