Welcome back.
Now, all we're doing in this electrocute spell pretty much is hiding the mouse cursor and showing it
again.
We're going to need to do better than that.
In this video.
We're going to play a montage.
Now we've added a montage electrocute variable.
But we don't have an electrocute montage for aura.
So we're going to make one.
Let's go to assets characters aura animations abilities.
And there should be a cast shock.
We can open that and see what it looks like.
And it's a really short animation.
It's just the beginning of a shock.
Or electrocute if you want to call it ability.
Now we have cast shock and we have cast shock loop and the loop is different.
Remember we added this to our state machine in the animation blueprint.
She'll be in this state when her in shock loop boolean is set.
That's something we have to remember to do.
And we even created an interface function, a blueprint implementable event that we can set when we're
in the shock loop.
So we'll remember to do that.
But for now I'd like to make a montage for Cast Shock.
This really, really short animation will make a montage out of that.
And before we make that, I'm going to scroll down and make sure that enable root motion is checked.
And it is.
So we can make a montage out of shock.
Let's right click create create and Add montage and we'll call this m underscore cast underscore electrocute.
And electrocute is going to get a couple of things right.
We're going to need a motion warping notify state.
So I'm going to change the name of this notify track to motion warping.
And I'm going to make another notify track for events.
And we'll add our notify state.
So I'm going to right click right here add notify state.
Choose motion warping.
And we'll go ahead and motion warp up to just before she juts out the staff.
So right about here and we need to go to the details panel.
Expand Route Motion modifier and change Warp Target name to Facing Target.
That's the same name we've been using for all of our motion warping targets.
And we're unchecking Warp Translation.
We're only warping rotation and setting rotation type to facing.
And in addition we're going to want a notify that can send an event right.
We're going to right click Add Notify and use our custom A and montage event.
We can select it and choose an event tag.
Now we do have the event montage Firebolt.
We don't have one for electrocute.
So I'd like to add a tag that we can send for electrocute as well.
So I'm going to go to Project Settings into Gameplay tags and take a look at event montage.
Here's Firebolt.
We're going to add one.
So next to montage I'll click plus.
That'll start me off with event montage.
And this will be called electrocute.
Now we'll have an electrocute tag that we can set here.
So now our montage will send an event with the electrocute tag.
So now that we have this montage with it selected in the content browser, we can go back to electrocute
and we can set that montage to this.
And I'm done with project settings.
I'm even done with Cast Electrocute.
I'm going to go ahead and save all.
And now that we have a montage, we can go about playing this montage.
Now, as is the case with Firebolts, we're going to want to update the warp target.
Now we can remind ourselves how we did that by going to Aura Abilities Fire and open a fire bolt.
How are we updating the warp target here?
Well, it looks like we're taking the avatar actor casting to combat interface and calling update facing
target.
Now, I seem to recall that we made this a blueprint native event though, didn't we?
Let's go to Combat Interface and take a look at update facing target.
So we see here that it's a blueprint implementable event blueprint callable.
So if we right click in here and type update facing target here's that interface message.
We can actually pass in an object reference.
We can just get the avatar actor from actor info and pass that in along with the target.
And we have a mouse hit location.
So if we call update facing target and then simply play a montage, then we should be able to see a
turn.
So let's try that.
We'll use play montage and wait.
And we'll plug in electrocute, montage, electrocute, and we'll just see if this works.
So we should see aura play the ability.
Now we can uncheck stop when ability ends.
So she's kind of twitching.
She kind of wants to cast that spell, but let's figure out why it's not working.
Let's go to our montage.
I'm going to set our blend times to a low value 0.01 for blend in.
And we'll go to blend out and set that to 0.01.
Let's see if that helps.
Okay, that's better.
And we see that we're able to get motion warping to work.
Now it looks kind of funny because it's such a fast spell.
You could slow this down.
You could go into the montage and set the rate scale maybe to 0.5.
I'm actually okay with it being fast.
So if you want it slower, you could use that.
But I'd like this to be a fast paced adventure.
So I'd like rate scale to be one.
And now we have our play montage and wait, we're updating the facing target.
We've seen that we don't need to cast to the interface, so we can even go into Firebolt, and we no
longer need to cast to the interface and pass that in.
We could just pass the avatar actor straight in by right clicking and using update facing target, using
the message that takes in a new object rather than the version that takes in the interface itself.
If we do that, we don't need to bother with this cast here.
We can just do this.
So we can test out our Firebolt and make sure that still works.
And of course it does.
So we've simplified this a little bit.
Not a lot, but a little.
Okay, so we're done with Firebolt for now.
I'm going to save all.
An electrocute now plays our electrocute montage, which is really just the start of the electrocute
spell.
Once we start, and as long as we're holding the mouse button down or whatever input is assigned to
this, I'd like to be in the shock loop, which means we're going to want to call that interface function.
Now, it's pretty important that our avatar actor implements the shock interface.
So the first thing we can do is check.
Does implement interface and we can get the avatar actor.
So from the actor info and the interface we're going to check is combat interface.
Now, if we don't implement this interface, there's no point in continuing any further.
So we can go ahead and just place this check straight away.
And in the false case we can just end the ability.
Now this should still work because while we do implement the interface.
And now we know it's safe to access functions and call them on that interface.
So really, this could just be collapsed to a function and we'll say enforce implements combat interface.
That'll keep things a little tidier.
Okay, now that we know we're implementing that interface, for sure, we want to do a couple things
here, like make sure that our characters in the shock loop and.
What I mean is, if we go into blueprints, character aura app aura and take a look at main states,
we have this in shock loop variable and we made a blueprint implementable event for Aura Character to
implement.
So here in the BP for aura character.
Right next to update facing target.
We can also implement.
Set in shock loop.
This is the event.
And what we can do here is set our in loop boolean variable we added in shock loop.
We can now set it.
And our app aura is setting.
It's in shock loop based on the characters in shock Loop here.
So if we set it on aura.
Then our animation blueprint will get it.
Yes, that's a middleman intermediary step.
You could bypass aura and just set it directly on the anim instance if you wanted to do that, but I'm
okay with doing it this way.
So now here in electrocute I want to set that so we can say set in shock loop.
And we made this an interface blueprint callable function.
So as soon as we start playing the montage we can just set this right away because the montage takes
over this state in the animation blueprint here.
So we can set in shock loop and aura will be in this state right here, but we won't see this pose,
will actually see the montage play, and only when the montage is done will be in the shock loop.
So we can set this state right away.
And in fact, we even want to.
Because if we waited till the montage was completed for example, well, that involves a blend in time
and the animation blueprint right here.
And then we'd have to go in and set the blend time here and make sure that we blend right away and things
like that.
But the easiest thing to do is just to set the state right away.
So we have in shock loop there, and we can copy these nodes and we can set in shock loop before we
end the ability as well.
And we'll set that to false.
So now.
If we play test this.
Now, as long as we're holding that mouse button down.
We see aura in the shock loop, and if we release, then she goes back.
And she goes back in a nice, smooth manner because again, the animation blueprint itself will blend
with its own blend settings.
If you want her to go back faster, you can change the duration for this from 0.2 to say 0.1.
She'll go back in a faster manner.
Like that.
I kind of liked 0.2, though.
I think it's nice and smooth.
And again, the montage has its own blend settings too.
So if you wanted the montage to blend in smoother, you could change that blend in time there.
So everything blends when it comes to animations, animation states, and montages in unreal.
So now we're playing the montage.
It looks great, and we're staying in that shock loop as long as we hold our input down.
Now that doesn't matter what input the ability is assigned to.
If we say assign the ability to the one key, for example, then if we press and hold the one key,
then we get the same thing.
Now?
Yes.
If we're moving and we cast the spell, we're interrupted by moving, of course.
So we're going to want to prevent movement while we're in that shock loop.
So for that reason, we're going to want the character movement component so that we can disable movement
on it.
And just like we had an owner player controller, we can have an owner character if we only want to
perform a cast from our avatar actor to a character once, we can just cast once, and because we're
storing the owner player controller, we can do it in this function.
And we could just call this a different name, like store owner variables or something like that.
So just to make this easy, I'm going to go to Aura Beam Spell.
We're going to have a new T object pointer.
This will be an A character.
And we'll call this owning character.
We'll make this also blueprint read, write.
And we'll set this and we'll call this function instead of store owner player controller.
Now we can just call it store owner variables.
And here in the definition.
Now store owner variables.
We can store not only the player controller but our owner character as well.
So what we can do is we can take our owner character.
And in fact we'll do this inside the if check here we'll say owner character.
And it's red.
And that's because I called it owning character.
Let's be consistent and call it owner character.
And I can set this equal to a cast to a character.
And I'll go ahead and cast current actor.
Info.
Dot and we have the avatar actor.
Now we just need to include this type.
And of course character is in game framework.
So we're going to include game framework character dot h.
And that includes it.
Notice that the player controller doesn't have such a requirement.
It's already included implicitly.
So now that we have this owner character and it should be set after store owner variables, then we
should be able to get its movement component and disable movement while we're doing this spell.
So we can go ahead and get our ability back open.
And here in electrocute, let's just go back to this node because it's no longer store owner player
controller.
We're going to replace it with store owner variables instead.
This function does more stuff now.
Okay.
Now, as soon as we're in the shock loop, we should also disable character movement by getting our
owner character.
And by the way, I'm just going to hit compile to get rid of those errors.
So I'm going to get owner character.
It's a character type, so we can get character movement.
The movement component.
And from that we can call disable movement.
Like so.
And if we disable movement, we won't be able to move.
But we got to remember to re enable movement later, right?
So how do we do that?
Well, the character movement component doesn't have a function called enable movement.
What it has is set movement mode.
And we can set it to walking and that's going to enable movement again.
So before we do that, let's just see how this works with disabling movement without enabling it back.
And let's try to move around.
I'm trying to actually do the wasD thing.
And I can't.
And before I cast the spell.
I can use to move as soon as I start the spell.
I can't.
Now notice motion warping doesn't work either.
We've completely disabled movement.
That includes root motion movement from motion warping, so we'll have to disable movement at a later
time.
But as soon as we are about to end the ability, let's get our character movement component and set
movement mode.
Two walking.
So I can move around with wasD.
I can right click and hold.
Can't move and if I release I can move again.
So setting that movement mode back to walking enables it.
The problem is that we don't get that motion warping if we disable movement before we motion warp.
So what's the easiest way to do?
When is the best place to disable movement?
Well, I don't want to do it when completed or blended out or anything like that.
What I'd rather do is wait for a gameplay event, and as soon as we get that gameplay event, which
we know we're sending from the montage, we can then respond to it.
So I'm going to call wait gameplay event and use the ability task.
And we'll do this right away.
We're not going to use any of these.
And as soon as an event is received, we'll hook this up to event received.
Then we can disable movement and be in shock loop and the event tag is going to be event dot montage,
dot electrocute.
And we only want to trigger once.
There we go.
So now this should work.
We can run around, we can shock and we can run around and motion warping works.
Perfect.
Now that's taking care of the animation side of things.
And to keep this blueprint under control, we're going to want to make sure things are nice and tidy
as much as we can.
So we know that if we're beginning our shock loop, we're going to want to disable movement, right?
And before we end the ability, we're going to want to prepare to end the ability by showing the mouse
cursor again setting in shock loop to false, setting the movement mode back right.
So this is all stuff that should happen at the end of the ability.
So we can collapse this all to a node.
Right click collapse the function.
And we can call this prepare to end ability.
And that's going to take care of the things that need to happen.
When we're about to end the ability and then setting the in shock loop and disabling movement.
This is all stuff we're handling for the shock loop.
So we're just going to call this one collapse the function.
In shock loop.
So we're setting those variables there and updating the facing target and showing the mouse cursor.
Those are actually two different things.
So we can have update facing target.
We can collapse that to a function and I'll just call it update facing target.
And then this one can just be showing the mouse cursor.
In fact, we could even have a function that takes in a boolean.
Or if you don't mind having two nodes, it might be overkill to refactor.
So I think so far that's okay.
Okay, so now we have our animations working for electrocute.
Things are looking pretty good.
Now we need to start working on other things, such as spawning the beam particles and such.
So we'll get the rest of this implemented in the videos to come.
I'll see you soon.