Welcome to your next quest.
In this quest, you're going to play an attack montage, so you should know how to do this.
You're going to do this in our new melee attack ability.
So go ahead and decide how you're going to go about making a montage and we'll go ahead and just use
an attack montage for the Goblin Spear.
And later, we'll work on making this ability reusable among other types of melee attackers.
So for now, pause the video and conquer this quest now.
Okay, we're going to want to play an attack montage.
So we're going to open up our brand new gameplay ability for attacks.
Let's go to Ability System in our blueprints folder, open up gameplay abilities and gar melee attack.
So here in Melee Attack, we're going to play a montage, right?
That means we need to use a play montage node and we're going to use the play montage and wait ability
task.
So for this we're just going to hardcode a montage for now, but we'll make this more versatile later.
We just want to get things working for now.
So for the montage to play, we need a montage, right?
And we only have hit React montages for the goblins.
We're going to need one for an attack.
So let's go to the assets folder into Enemies Goblin and animations and spear and we have our spear
goblin animations.
We're going to want an attack.
And here we have Attack spear.
This is going to be just perfect for us.
Let's make a montage based on this.
So I'm going to right click on Attack Spear.
We're going to use Create, Create and a montage and we're going to call this Am underscore attack Goblin
Spear.
And just to be consistent with my hit React, there will be no underscore between Goblin and spear.
So we have an attack goblin.
Spear.
Right.
So for now, that's all I want to do is just create this attack montage.
We'll go ahead and use this in Gar melee attack and play montage and wait, we're going to use Attack
Goblin Spear and just play that montage.
Now, as soon as this montage has completed, I'm going to end the ability.
So we're going to use end ability like this.
And there we have it.
Our ability plays a montage.
So let's see how this works by pressing play and we'll see our goblin spear run up to us.
And there we go.
It's attacking.
Now it moves to another location and then it attacks again.
So this is looking pretty good.
And there's a couple of issues.
For one, I saw that the goblin is attacking not quite straight on sometimes.
Sometimes it attacks with its spear off to the side.
So that's something we're going to want to work on, but that's something we could fix as we've fixed
this kind of issue before.
With Aura, you see, if Aura is launching an ability behind her, she turns around.
Why?
Because she has a root motion attack animation, and we're using motion warping.
How are we using motion warping?
Well, we can go into blueprints, into character aura and open up aura character.
And we have this event update facing Target where we're getting our motion warping component on aura,
which we added on the blueprint and we're using Add or update warp target from location.
So we have this event, this interface event update facing Target.
Now why can't we just do this for the enemy as well?
Just to remind ourselves, if we go into our combat interface, here is that event.
It's a blueprint, implementable event, blueprint callable, and it's called Update facing Target,
which takes an F vector by const reference called Target.
So there's no reason why we can't implement this on the enemy class.
And in fact, we have a base enemy blueprint that we can use BP enemy base, we can implement that interface
function here.
It's called Update facing Target.
Now there's the function call because it's blueprint callable, and then there's the event because it's
blueprint implementable event.
We want the event so we can decide what happens when the function gets called for the enemy.
Now, the enemy doesn't have a motion warping component like BP or a character, so we're going to need
to add one to enemy base.
We're going to click Add and let's search for motion warping.
Here it is.
We can add the motion warping component, we can drag it out and we can do what we did in Aura character
add or update warp target from location choosing, facing target.
So let's do that.
We're going to call Add or update warp target from location and we're going to choose to use the same
naming convention facing target for the warp target name.
And we're going to use the target as the target location and hook that up.
So now if our enemy is ever playing a root motion montage that has a motion warping notify State with
facing target as the warp target name, then this is going to set that warp target.
So all we need to do is call update facing target and we can make our enemies rotate to face a facing
target.
So let's go to our attack Goblin Spear and we can simply add a notify state with that facing target
warp target name.
So I'm going to go down to the notifies and rename the first track to Motion warping, and I'm going
to right click on that track, add, notify state and choose motion warping.
And I'm going to put this pretty close to the beginning and I'm going to grab the other end, the right
hand side of it, hold shift so I can preview the animation at that point.
And I'd like to warp to just about right here before the enemy starts that thrust.
So we'll rotate to face the target by here and then we'll thrust at that target.
So with motion warping this notify state selected, we can configure it by expanding root motion modifier
and changing the warp target name.
Now, back in enemy base, we see that that warp target name that we should use is facing target.
So we're going to call that warp target name facing target.
Now we only want to warp rotation.
So what we can do is we can uncheck warp translation.
Now we only have warp rotation and for rotation type I want facing.
So we'll rotate to face that target.
So now we're all set up to use motion warping.
The only thing left is to actually call this function update facing target with an appropriate target
to face.
So what do we want to rotate to face?
Well, if we're in melee attack on this enemy, we want to rotate to face aura, the thing that this
enemy is trying to attack now, it doesn't really have a reference to aura.
It needs some kind of variable for a combat target.
So what we're going to do is add a combat target to the enemy so that it can rotate to face that combat
target.
And then we need to access that combat target here.
We also need to set that combat target somehow.
So in the next video, we're going to add a combat target.
Target variable to our enemy so that it can use that combat target to motion warp towards that target,
to face that target every time the enemy attacks with a melee attack.
And we'll do that next.
So great job and I'll see you soon.